I have a list of dictionaries as follows:
[{"vins": "50EA1LGA5KA900001", "use": "abc", "owner": "Jack"}, {"vins": "50EA1LGA0KA900004", "use": "xyz", "owner": "Laura"}, {"vins": "50EA1LGA2KA900005", "use": "pqr", "owner": "Sam"}]
I want to write the above dictionary by creating a new influx measurement called 'vin_info' as follows: The output I expect is :
vins | use | owner
50EA1LGA5KA900001 | abc | Jack
50EA1LGA0KA900004 | xyz | Laura
50EA1LGA2KA900005 | pqr | Sam
The code I tried so far to write my data is:
data = [{"vins": "50EA1LGA5KA900001", "use": "abc", "owner": "Jack"}, {"vins": "50EA1LGA0KA900004", "use": "xyz", "owner": "Laura"}, {"vins": "50EA1LGA2KA900005", "use": "pqr", "owner": "Sam"}]
db = 'abc'
query = 'select * from vin_info'
client = InfluxDBClient(host='*****', port=8086,database=db)
print("Connection Established")
client.write_points(data)
result = client.query(query)
print(result)
But getting the following error:
AttributeError: 'str' object has no attribute 'get'
I am not sure how to insert the above data into influx measurement. Can someone please help me here.
Thanks in advance!
You are calling the measurement
vin_info
, which doesn't appear in the data.Try this:
You should see all tags when you select the measurement.
Also, according to
influxDBClient
doc, query return a table.So try this also: