zoukankan      html  css  js  c++  java
  • InfluxDB时序数据库安装与使用

    1. 下载解压文件

     2.启动服务,双击运行influxd.exe

    3.安装客户端工具(InfluxDBStudio)

     4.新建数据库

    5. NuGet -> InfluxData.Net

    using InfluxData.Net.InfluxDb.Models;
    using System;
    using System.Collections.Generic;
    
    namespace InfluxDBTest
    {
        class Program
        { 
            static void Main(string[] args)
            {
                string table = "logInfo";
                var point_model1 = new Point()
                {
                    Name = table,//表名 
                    Tags = new Dictionary<string, object>() { { "Id", "5810953" } }, // 索引
                    Fields = new Dictionary<string, object>() { { "Val", 102 } },// 字段
                    Timestamp = DateTime.UtcNow
                };
    
                var point_model2 = new Point()
                {
                    Name = table,//表名
                    Tags = new Dictionary<string, object>() { { "Id1", "5810951" }, { "Id2", "5810952" } },
                    Fields = new Dictionary<string, object>() { { "Val1", 101 }, { "Val2", 102 } },
                    Timestamp = DateTime.UtcNow
                };
    
                var queries = new[] 
                {
                    " SELECT time,Id,Val FROM " + table+ " WHERE time> now() -  24h "
                };
    
                InfluxDbHelper.Init();
    
                InfluxDbHelper.Write(point_model1);
                InfluxDbHelper.Write(point_model2);
    
                //InfluxDbHelper.Read(queries).Wait();// 异步转同步
                IList<IList<object>> result = InfluxDbHelper.Read(queries).GetAwaiter().GetResult();
                for (int i = 0; i <result.Count; i++)
                {
                    var lstTemp = result[i];
                    Console.WriteLine("time:" + lstTemp[0] + ",id:" + lstTemp[1] + ",val:" + lstTemp[2]);
    
                    //for (int j = 0; j < lstTemp.Count; j++)
                    //{
                    //    object content = lstTemp[j];
                    //    Console.WriteLine(content);
                    //}
                }
    
                Console.ReadKey();
            }
        } 
    }

    qq:505645074
  • 相关阅读:
    List集合中的对象按照某个字段去重实现
    菜单--微信提醒
    fastTime从后台传过来显示格式的处理
    彻底卸载Oracle
    关于这次安装Oracle
    关于下拉选择删选最基本一例(分享内容)
    马拉松参赛人员显示(瞬逝版)
    马拉松参赛人员旧版本最终版(私藏版)
    win 10 初始环境变量
    AngularJS输出helloworld
  • 原文地址:https://www.cnblogs.com/chen1880/p/14804969.html
Copyright © 2011-2022 走看看