时序库influxdb2+Net6(分表,联表查询)
http://127.0.0.1:8086
admin
12345678
using InfluxDB.Client.Api.Domain; using InfluxDB.Client.Writes; using Influxdb2.Example.model; using Influxdb2.Example.model.db; using Influxdb2.Example.Util; namespace Influxdb2.Example { internal class Program { static string url = "http://127.0.0.1:8086"; static string token = "kYFVcao_7JqOMr_QHztGi4kpy-y0Z7MoqZVWu4rix-PNpzszWxcVFrMij8MAJWqObcXcLhrZ5D08BZxUQtsVlw==";// token static string org = "abc";//用户组 static string bucket = "a1";//数据库 static void Main(string[] args) { Test(); Console.ReadLine(); } static async Task Test() { InfluxdbHelper.Init(url, token, org, bucket); string table = "DeviceLog_" + (DateTime.Now).ToString("yyyyMMdd"); var now = Common.GetNow(); string key = now.Item1; var value = now.Item2; List<PointData> lstPoint = new List<PointData>(); var point = PointData.Measurement(table).Timestamp(Common.GenerateUniqueDateTime(), WritePrecision.Ns).Tag(BaseData.DeafultT, BaseData.DeafultT); lstPoint.Add(point.Field(BaseData.DeafultF, BaseData.DeafultF)); lstPoint.Add(point.Field("DeviceNo", "DZ001")); lstPoint.Add(point.Field("Temperature", 26.5)); lstPoint.Add(point.Field("LogTime", key)); lstPoint.Add(point.Field("LogTimestamp", value)); await InfluxdbHelper.WritePoints(lstPoint); // 分页查询 var pageData1 = await InfluxdbHelper.GetLog<DeviceLog>("", "2025-01-30 00:00:00", "", 1, 1); // 查询所有 var pageData2 = await InfluxdbHelper.GetLog<DeviceLog>("", "2025-01-30 00:00:00", "", 0, 0); Console.Write("End"); } } }
qq:505645074