Error in querying influxDB data from Python Client

Hi there,

I am using Python Influx Client library and getting HTTP response error. Here’s how I am trying to query:



query = 'from(bucket:"PythonClient") |> range(start: -10m) |> filter(fn:(r) => r._measurement == “Company”)'

#tables = query_api.query('from(bucket:"PythonClient") |> range(start: -10m)')
result = client.query_api().query(org=org, query=query)

results = []
for table in result:
    for record in table.records:
        results.append((record.get_value(), record.get_field()))
print(results)

Error:
HTTP response headers: HTTPHeaderDict({‘Content-Type’: ‘application/json; charset=utf-8’, ‘Vary’: ‘Accept-Encoding’, ‘X-Platform-Error-Code’: ‘invalid’, ‘Date’: ‘Thu, 29 Jul 2021 20:04:50 GMT’, ‘Transfer-Encoding’: ‘chunked’})
HTTP response body: b’{“code”:“invalid”,“message”:“compilation failed: error at @1:61-1:99: invalid expression @1:99-1:102: \xe2\x80\x9d”}'4

Any feedback on this would be great help. Thanks

Hello @raginigupta6,
I noticed that you use different types of quotes in your query can you please try changing this

query = 'from(bucket:"PythonClient") |> range(start: -10m) |> filter(fn:(r) => r._measurement == “Company”)'

to

query = ''' from(bucket: "PythonClient") |> range(start: -10m) |> filter(fn:(r) => r._measurement == "Company") '''

1 Like

Thanks, it’s working now :slight_smile:

1 Like

@raginigupta6,
Of course no problem :slight_smile: