Hello Guys
I used to query my influxdb data using Python, the influxdb library and DataFrameClient. The Python API states to use the newer (influxdb-client) for v1.8+ and v2. As we are running Influxdb v1.8.1 I decided to switch to the influxdb-client and rework my Jupyter Notebooks. So I enabled Flux and tried to query the data using Pandas DataFrames (with the help of DataFrame and Flux examples). Using
from influxdb_client import InfluxDBClient, Point, Dialect
from influxdb_client.client.write_api import SYNCHRONOUS
client = InfluxDBClient(url="http://localhost:8086", token="username:password")
query_api = client.query_api()
df = query_api.query_data_frame('from(bucket:"MyDatabase/autogen") '
'|> range(start: 2020-08-25T00:00:00Z, stop:2020-08-25T01:00:00Z)'
'|> filter(fn: (r) => r._measurement == "MyMeasurement" and r._field == "MyColumn"')
I get the following Error:
ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Request-Id': 'ba3e82d7-f0ef-11ea-8b7e-00155d6fb6df', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Error': 'loc 1:103-1:187: expected RPAREN, got EOF', 'X-Influxdb-Version': '1.8.1', 'X-Request-Id': 'ba3e82d7-f0ef-11ea-8b7e-00155d6fb6df', 'Date': 'Mon, 07 Sep 2020 09:51:40 GMT', 'Content-Length': '54'})
HTTP response body: b'{"error":"loc 1:103-1:187: expected RPAREN, got EOF"}\n'
Leaving out the filter I get a response of a List with several tables but not the desired Information for the Measurement. Moreover I’m using “database/retention policy” for the bucket and “username:password” for the authentification token as stated for the v1.8/v2 compatibility. I also tried to add the |> yield()
-Statement but without success, still the same error.
Does someone know how to use the Flux filter properly regarding influxdb-client and Python? Do we have to switch to Influxdb v2?
I’m running Python 3.7.4, InfluxDB 1.8.1, influxdb-client 1.10.0 and pandas 1.0.3 on Windows 10.
Thanks in advance.