• TDengine HelloWorld


    安装
    https://www.taosdata.com/cn/getting-started/

    $ tar -xvzf TDengine-server-2.3.0.0-beta-Linux-x64.tar.gz
    $ cd TDengine-server-2.3.0.0
    $ ./install.sh

    默认信息
    端口 6030
    用户:root
    密码:taosdata

    $ taos
    $ create database power KEEP 365; // 建库(保留365天)
    $ USE power;
    $ CREATE STABLE meters (ts timestamp, current float, voltage int) TAGS (location binary(64), groupdId int); // 创建超级表(电表:电流+电压,标签)
    $ INSERT INTO d1001 USING meters TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219); // 自动创建子表

    解决客户端连接报错"Unable to resolve FQDN"

    1. 查询TDengine所在Linux服务端的hostname

    2.

    对于Linux系统的客户端,在/etc/hosts文件添加如下的一条记录:192.168.1.131 chen

    对于Windows系统的客户端,在C:WindowsSystem32driversetchosts文件中添加如下一条记录:192.168.1.131 chen

     

    添加NuGet引用“Maikebing.Data.Taos”

    using Maikebing.Data.Taos;
    using System;
    
    namespace TDengineTest
    {
        class Program
        {
            /// <summary>
            /// 时间戳计时开始时间
            /// </summary>
           static DateTime timeStampStartTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    
            /// <summary>
            /// DateTime转换为13位时间戳(单位:毫秒)
            /// </summary>
            /// <param name="dateTime"> DateTime</param>
            /// <returns>13位时间戳(单位:毫秒)</returns>
            static long DateTimeToLongTimeStamp(DateTime dateTime)
            {
                return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalMilliseconds;
            }
    
            static void Main(string[] args)
            {
                string database = "power";//"db_" + DateTime.Now.ToString("yyyyMMddHHmmss");
                var builder = new TaosConnectionStringBuilder()
                {
                    DataSource = "chen",
                    DataBase = database,
                    Username = "root",
                    Password = "taosdata",
                    Port = 6030
                };
    
                using (var connection = new TaosConnection(builder.ConnectionString))
                {
                    DateTime dtNow = DateTime.Now;
    
                    connection.Open();
    
                    connection.CreateCommand($"drop stable {database}.meters;").ExecuteNonQuery();
    
                    connection.CreateCommand($"create stable {database}.meters (timevalue timestamp, timekey bigint, current float, voltage int) TAGS (location binary(64), groupdId int);").ExecuteNonQuery();
    
                    connection.CreateCommand($"insert into d1001 using meters TAGS('Beijng.Chaoyang', 2) values ('{ dtNow.ToString("yyyy-MM-dd HH:mm:ss.ms") }', { DateTimeToLongTimeStamp(dtNow) }, 10.2, 219)").ExecuteNonQuery();
    
                    var cmd_select = connection.CreateCommand();
                    cmd_select.CommandText = $"select * from meters";
                    var reader = cmd_select.ExecuteReader();
                    var d = reader.ToDataTable();
    
                    cmd_select.CommandText = $"select * from d1001";
                    var reader1 = cmd_select.ExecuteReader();
                    var d1 = reader1.ToDataTable(); 
    
                    connection.Close();
                }
    
                Console.ReadKey();
            }
        }
    }
    

      

    TDengine 服务端 客户端 版本要一致

     参考资料

    https://github.com/maikebing/Maikebing.EntityFrameworkCore.Taos

    https://www.taosdata.com/blog/2020/09/08/1816.html

    https://juejin.cn/post/6902286172711157768

    qq:505645074
  • 相关阅读:
    使用jMeter测试通过SAP ID Service认证的SAP Cloud API
    在SAP C4C里使用Restful服务消费SAP S/4HANA的标准功能
    SAP S/4HANA Cross Selling机制介绍
    如何用代码读取SAP CRM的Categorization Schema
    SAP Enterprise Commerce调试环境搭建
    使用jconsole监测SAP commerce运行时
    SAP Commerce开发之如何找到某个页面对应的JSP实现页面
    KubeEdge在国家工业互联网大数据中心的架构设计与应用
    从云数据迁移服务看MySQL大表抽取模式
    CSS开发过程中的20个快速提升技巧
  • 原文地址:https://www.cnblogs.com/chen1880/p/15480213.html
Copyright © 2020-2023  润新知