influxdb.py 560 B

1234567891011121314
  1. from influxdb_client import InfluxDBClient, Point
  2. from influxdb_client.client.write_api import SYNCHRONOUS
  3. class Database():
  4. def __init__(self):
  5. self.client = InfluxDBClient(url="http://localhost:8086", token="DTvugv1tGXDYplEjgBduFTBItsa3WAyfZ5Dw5P3xZPDr37ZqNDmwOm-wtCK0z2jr6bUyb0Qj94nDB4jmR52siA==", org="laempe")
  6. self.bucket = "energy-monitor"
  7. self.write_api = self.client.write_api(write_options=SYNCHRONOUS)
  8. self.query_api = self.client.query_api()
  9. def write(self, point):
  10. self.write_api.write(bucket=self.bucket, record=point)