I'm trying to insert a simple json data into the InfluxDB 2.x using python client: influxdb_client.
The code create the measurement and all the fields and tags but it does not insert the data.
This is how I'm connecting to InfluxDB:
from datetime import datetime
from influxdb_client import InfluxDBClient as FluxDBClient
from influxdb_client import Point, WriteOptions
from influxdb_client .client.write_api import SYNCHRONOUS
api_token = "gC4vfGRHOW_OMHsXtLBBDnY_heI76GkqQgZlouE8hNYZOVUVLHvhoo79Q-5b0Tvj82rmTofXjywx_tBoTXmT8w=="
org = "0897e8ca6b394328"
client = FluxDBClient(url="http://localhost:8086/", token=api_token, org=org, debug=True, timeout=50000)
Here is the code to insert data:
points = [{
"measurement": "temp",
"time": datetime.now(),
"tags": {
"weather_station": "LAHORE",
"module_detail_id": 1,
},
"fields": {
"Rad1h": 1.2,
"TTT": 100,
"N": 30,
"VV": 20,
"power": 987,
}
}]
options = WriteOptions(batch_size=1, flush_interval=8, jitter_interval=0, retry_interval=1000)
_write_client = client.write_api(write_options=options)
_write_client.write("Test", "0897e8ca6b394328", points)
_write_client.__del__()
client.__del__()
When I run the script, I get 204 response in return, which means that the write query is executed successfully. But I'm getting no record, as you can see in the image below: