EvaluationEfficiencyOptimiz.../davisAPI/ulstu_influx.py

27 lines
993 B
Python
Raw Normal View History

2024-10-08 17:47:23 +04:00
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
bucket = "wind"
client = InfluxDBClient(url="http://influxdb.athene.tech/",
token="2CEePET3ss2khtjsdGrJap8mVzHhR2dRwuyK3NuFBvDgGtOMSi6Jstsrp2o-OANzD8fxB73PsTyIbqgbnokoXQ==",
org="UlSTU")
write_api = client.write_api(write_options=SYNCHRONOUS)
query_api = client.query_api()
# p = Point("my_measurement").tag("location", "Prague").field("val", 200.0)
#
# write_api.write(bucket=bucket, record=p)
tables = query_api.query('from(bucket:"wind") |> range(start: -7d)')
for table in tables:
print(table)
for row in table.records:
print (row.values)
print(row.values['_field'])
print(row.values['_value'])
# manger = InfluxManager("wind","http://localhost:8086","IkRV5NlnRp_fTHR5x4mgMzi_coQ31ILQBaQUf5wZfXIJ9iwCZBH9qiHnSREgdu_bdsmAjUisUTmqoMvpXDXUOA==","nikitaOrganization")
# print(manger.getDataByTime())