我有一个字典列表如下:
[{"vins": "50EA1LGA5KA900001", "use": "abc", "owner": "Jack"}, {"vins": "50EA1LGA0KA900004", "use": "xyz", "owner": "Laura"}, {"vins": "50EA1LGA2KA900005", "use": "pqr", "owner": "Sam"}]
我想通过创建一个名为“vin_info”的新流入测量来编写上述字典,如下所示:我期望的输出是:
vins | use | owner
50EA1LGA5KA900001 | abc | Jack
50EA1LGA0KA900004 | xyz | Laura
50EA1LGA2KA900005 | pqr | Sam
到目前为止,我尝试写入数据的代码是:
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)
但得到以下错误:
AttributeError: 'str' object has no attribute 'get'
我不确定如何将上述数据插入到流入测量中。有人可以在这里帮助我吗?
提前致谢!