NetPro.Tdengine 6.0.16

dotnet add package NetPro.Tdengine --version 6.0.16
NuGet\Install-Package NetPro.Tdengine -Version 6.0.16
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPro.Tdengine" Version="6.0.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.Tdengine --version 6.0.16
#r "nuget: NetPro.Tdengine, 6.0.16"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetPro.Tdengine as a Cake Addin
#addin nuget:?package=NetPro.Tdengine&version=6.0.16

// Install NetPro.Tdengine as a Cake Tool
#tool nuget:?package=NetPro.Tdengine&version=6.0.16

NetPro.Tdengine使用

NuGet

涛思数据库连接对象Maikebing.Data.Taos的简易封装,使用单例TaosConnection对象

客户端驱动下载地址 客户端与服务器版本必须强一致;

即使使用ip连接,也必须配置fqdn:

  • 服务器执行以下命令获取服务器的fqdn值
taosd | grep -i fqdn
  • 修改hosts域名解析 添加服务器ip对应的fqdn值作为域名
  • 修改C:\TDengine\cfg 配置
# local fully qualified domain name (FQDN)
fqdn                      h26.taosdata.com  #taos数据库远程hostname,既fqdn

# first port number for the connection (12 continuous UDP/TCP port number are used) 
serverPort                6030 #客户端连接端口,默认6030,udp

windows本地客户端测试

.\taos.exe -h h26.taosdata.com -P 6030

响应以下即成功,显示客户端版本为2.4.0.7,服务器必定也是2.4.0.7版本

Welcome to the TDengine shell from Windows, Client Version:2.4.0.7
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.

Tdengine时区 修改

修改C:\TDengine\cfg下的taos.cfg配置文件中的timezone节点与服务器保持一致; 特别注意Tdengine执行的时区标准为 unix的时间标准,与传统的东8 是+8不一样,在Tdengine需配置为UTC-8

# system time zone
timezone              UTC+0  #0时区(伦敦时间)

#timezone              UTC-8  #东八区(北京时间)

restful 方式访问Tdengine需注意

官方restful调用文档

调用 rest/sql ,响应时间以服务器时区为准,并且格式为 2022-02-17 12:31:45.375 调用 rest/sqlt,响应时间为unix时间戳

使用

appsetting.json
"TdengineOption": {
    "ConnectionString": [
      {
        "Key": "taos1", //连接串key别名,唯一
        "Value": "Data Source=h26.taosdata.com;DataBase=db_20220120141621;Username=root;Password=taosdata;Port=6030" //别名key对应的连接串
      }
    ]
  },

启用服务

没有基于NetPro.Web.Api 的使用场景,必须手动进行初始化,如下:

IConfiguration Configuration;

public void ConfigureServices(IServiceCollection services)
{
     services.AddTdengine(Configuration);
}

基于NetPro.Web.Api的使用,只需要添加引用后配置以上appsetting.josn配置TaosOption节点即可

当想自定义连接字符串获取方式时,无论是否基于NetPro.Web.Api, 都能通过传入委托来自定义连接字符串获取方式:

public void ConfigureServices(IServiceCollection services)
{
    services.AddTdengineDb(GetConnectionString);
}

public List<ConnectionString> GetConnectionString(IServiceProvider serviceProvider)
{
    return new List<ConnectionString>
    {
        new ConnectionString()
        {
            Key ="remotekey",
            Value = "Data Source=h26.taosdata.com;DataBase=db_netpro;Username=root;Password=taosdata;Port=6030"
        }
    };
}

使用说明

 public class TaosService: ITaosService
    {
        private readonly TdengineMulti _taosdbMulti;
        public TaosService(TdengineMulti taosdbMulti)
        {
            _taosdbMulti = taosdbMulti;
        }

        /// <summary>
        /// 执行Sql
        /// </summary>
        public void Executesql(string sql)
        {
            using  var taos= _taosdbMulti.Get("taos1");
            using var command= taos.CreateCommand(@"INSERT INTO  data_history_67 
                                 USING datas TAGS (mongo, 67) 
                                 values ( 1608173534840 2 false 'Channel1.窑.烟囱温度' '烟囱温度' '122.00' );");
            using var reader= command.ExecuteReader();//command和reader都必须using
        }
    }
更新中...
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.16 141 7/24/2023
6.0.15 378 7/19/2022
6.0.14 391 7/10/2022
6.0.13 378 6/15/2022
6.0.12 374 6/15/2022
6.0.11 379 6/15/2022
6.0.10 391 6/11/2022
6.0.9 400 6/8/2022
6.0.8 379 5/26/2022
6.0.8-beta.3 107 5/24/2022
6.0.8-beta.2 103 5/24/2022
6.0.7 387 5/18/2022
6.0.6 399 4/28/2022
6.0.5 415 3/30/2022
6.0.5-beta.20 106 4/27/2022
6.0.5-beta.19 110 4/25/2022
6.0.5-beta.18 107 4/22/2022
6.0.5-beta.17 106 4/16/2022
6.0.5-beta.16 104 4/8/2022
6.0.5-beta.15 113 4/8/2022
6.0.5-beta.14 118 4/7/2022
6.0.5-beta.13 114 4/7/2022
6.0.5-beta.12 112 4/6/2022
6.0.5-beta.11 114 4/6/2022
6.0.5-beta.10 117 3/31/2022
6.0.5-beta.9 119 3/26/2022
6.0.5-beta.8 114 3/22/2022
6.0.5-beta.7 108 3/21/2022
6.0.5-beta.6 111 3/14/2022
6.0.5-beta.5 113 3/2/2022
6.0.5-beta.4 109 2/22/2022
6.0.5-beta.3 111 2/18/2022
6.0.5-beta.2 107 2/18/2022
6.0.5-beta.1 117 2/16/2022