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="XPBViJ3s4JL9_wPffwd5M2EgXj5hcUgT0n4jNhv7m6-NC-6SSxQ3run4kXtWBvOk-FYr1VG5Tj5WcoHgjge9jw==", 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)