【发布时间】:2018-03-13 00:07:36
【问题描述】:
Python 版本 - 2.7 InfluxDB 版本 - 1.5.0
我是新手,我正在尝试将我的 InfluxDB 数据库与 Python 连接起来,以便为未来的项目编写代码。
我从link 测试了示例程序。 (下面直接代码)
from influxdb import InfluxDBClient
json_body = [
{
"measurement": "cpu_load_short",
"tags": {
"host": "server01",
"region": "us-west"
},
"time": "2009-11-10T23:00:00Z",
"fields": {
"value": 0.64
}
}
]
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')
client.create_database('example')
client.write_points(json_body)
result = client.query('select value from cpu_load_short;')
print("Result: {0}".format(result))
运行程序时,我收到此错误。
Traceback (most recent call last):
File "influxentryexample.py", line 19, in <module>
client.create_database('example')
File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 318, in create_database
status_code=201
File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 124, in request
raise InfluxDBClientError(response.content, response.status_code)
influxdb.client.InfluxDBClientError: 404: 404 page not found
【问题讨论】:
-
看来你没有正确安装influx db驱动到python,请检查一下。 stackoverflow.com/questions/36846975/…