Advertisement
Guest User

Untitled

a guest
Dec 29th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from influxdb import InfluxDBClient
  2. import time
  3. import random
  4. import json
  5. import datetime
  6.  
  7.     #ustawienia bazy danych
  8. client = InfluxDBClient(host='localhost', port=8086)
  9. client = InfluxDBClient(host='localhost', port=8086, username='myuser', password='mypass', ssl=False, verify_ssl=False)
  10. client.create_database('grafana')
  11. client.switch_database('grafana')
  12.  
  13.     #InfluxDB send JSON
  14. def grafana():
  15.  
  16.     json_body = [
  17.         {
  18.             "measurement": "odleglosc",
  19.             "time": datetime.datetime.now(),
  20.             "fields": {
  21.                 "value": adc_value
  22.             }
  23.  
  24.         }]
  25.  
  26.     client.write_points(json_body)     
  27.        
  28.        
  29.        
  30.        
  31.     #petla glowna
  32.  
  33. while True:
  34.     grafana()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement