17 lines
546 B
Python
17 lines
546 B
Python
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
|
from influxdb_client.client.write_api import SYNCHRONOUS
|
|
|
|
token = "chOaOOaMs1QpQaYwYgj3TWT-z1LxuoWP_YC7M0rrFqFwNDVnGzyGKrUMqSPHN0_xPOgyEzedKu3i8wbCLVHyFg=="
|
|
org = "main"
|
|
bucket = "power"
|
|
|
|
client = InfluxDBClient(url="http://localhost:8086", token=token, org=org, timeout=30000)
|
|
write_api = client.write_api(write_options=SYNCHRONOUS)
|
|
|
|
|
|
def writeToDB(dataPoints):
|
|
""" Writes measurement to influx
|
|
"""
|
|
write_api.write(bucket, record=dataPoints)
|
|
print("Added to DB")
|