Is it possible to somehow insert list as a value in InfluxDB? This is the json:
json_body = [
{
"measurement":"devices",
"tags":{
"host":"server01",
"region":"us-west"
},
"fields": {
"device":1234,
"coord":[60.177751,24.913778],
"local":[[244,5,'232E','F27B',23],[244,5,'232F','76FE',9]]
}
}
]
Alternative would be to use string representation of list but then I have to convert it to list like below, which works fine.
ast.literal_eval(device_points[0]['local'])
Here is the json object with string representations:
json_body = [
{
"measurement":"devices",
"tags":{
"host":"server01",
"region":"us-west"
},
"fields": {
"device":1234,
"coord":"[60.177751,24.913778]",
"local":"[[244,5,'232E','F27B',23],[244,5,'232F','76FE',9]]"
}
}
]
client.write_points(json_body)
query = 'select local from devices;'
print("Querying data: " + query)
result = client.query(query)
device_points = list(result.get_points(measurement='devices'))
Is there some other way to achieve writing of lists directly?
Thanks!
There isn't a way to store lists as fields in InfluxDB. A common work around is to split the vector components out into individual fields.