influxd
influx
> CREATE DATABASE mydb
> USE mydb
pip install influxdb
python
from influxdb import InfluxDBClient
client = InfluxDBClient(host='localhost', port=8086)
client.switch_database('mydb')
json_body = [
{
"measurement": "temperature",
"tags": {
"location": "room1"
},
"time": "2022-01-01T12:00:00Z",
"fields": {
"value": 25.5
}
},
{
"measurement": "humidity",
"tags": {
"location": "room1"
},
"time": "2022-01-01T12:00:00Z",
"fields": {
"value": 60.2
}
}
]
client.write_points(json_body)
python
from influxdb import InfluxDBClient
client = InfluxDBClient(host='localhost', port=8086)
client.switch_database('mydb')
query = 'SELECT * FROM temperature'
result = client.query(query)
for point in result.get_points():
print(f"Time: {point['time']}, Value: {point['value']}")