我正在使用 influxdb 尝试'measurements'
使用 influxdb v4.0.0 在本地 influxdb 上写一些...
我有点困惑,因为有些地方说你使用 dict 或者你可以使用 json 和/或 line 协议....
从这里http://influxdb-python.readthedocs.io/en/latest/examples.html#tutorials-pandas从这里和这里https://github.com/influxdata/influxdb-python/blob/master/influxdb/客户端.py
1st -创建数据库对象:
InfluxDBClient('localhost', database='DBNAME')
2nd -使用数据创建字典:
measurement = {}
measurement['measurement'] = 'energy'
measurement['tags'] = {}
measurement['fields'] = {}
measurement['tags']['MeterID'] = str(meterId)
measurement['fields']['Energy_Wh'] = str(eFrame.getReading())
3rd -将数据推送到 BD:
try:
self.db.write(measurement)
except Exception as e:
print e
该程序有效,但没有数据存储在数据库中,而是我的控制台输出如下:
2017-01-11 12:41:09,741 - INFO - Saving Meter: MeterId = 09060178
u'points'
Meter-ID: 09060178 Energy Value (Wh): 10380300
{'fields': {'Energy_Wh': '10380300'}, 'tags': {'MeterID': '09060178'}, 'measurement': 'energy'}
1line logger file info
2line error/Exception
3line value returned by device
4line generated dict
(prints except logging are executed last)
我似乎无法找到我写错的原因或内容以及u'points'
错误的含义......有人可以帮忙吗?