我有这段代码来查询流入数据库,但它根本不起作用。这是python代码。
import os
from influxdb import InfluxDBClient
username = u'{}'.format(os.environ['INFLUXDB_USERNAME'])
password = u'{}'.format(os.environ['INFLUXDB_PASSWORD'])
client = InfluxDBClient(host='127.0.0.1', port=8086, database='data',
username=username, password=password)
result = client.query("SELECT P_askbid_midprice1 FROM 'DCIX_OB' WHERE time > '2018-01-01';")
我收到以下错误,但仍不清楚如何修复上面的代码。如果我使用 bash 直接从 influxdb 查询,SELECT P_askbid_midprice1 FROM 'DCIX_OB' WHERE time > '2018-01-01';
它工作得非常好。
Press ENTER or type command to continue
Traceback (most recent call last):
File "graph_influxdb.py", line 11, in <module>
result = client.query("SELECT P_askbid_midprice1 FROM 'DCIX_OB' WHERE time > '2018-01-01';")
File "/home/ubuntu/.local/lib/python3.5/site-packages/influxdb/client.py", line 394, in query
expected_response_code=expected_response_code
File "/home/ubuntu/.local/lib/python3.5/site-packages/influxdb/client.py", line 271, in request
raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"error parsing query: found DCIX_OB, expected identifier at line 1, char 31"}
我该如何解决?