Hi,
I’m using the Influx Python3 library to query an InfluxDB (2.6.1). The query I’m working on at the moment will return an empty set of results at times and this is expected.
How can I check a set of results to see if they are empty or not before processing them?
The query:
open_query = ' from(bucket:"' + influx_client_bucket + '")\
|> range(start: -1d)\
|> filter(fn: (r) => r["_measurement"] == "a")\
|> last()\
|> filter(fn: (r) => r["_value"] == 1)\
|> drop(columns: ["_start", "_stop", "_time", "_field", "_measurement", "_value"])'
open_query_result = query_api.query(org=influx_client_org, query=open_query)
As per this: Empty condition for Result Set in Python Client
The problem is even though the query returns 0 results the length of the result set is not 0:
print(len(open_query_result))
1
for table in open_query_result:
... for record in table.records:
... print((record.values.get("SOMETHINGHERE")))
...
None
What is the current method for checking that a query has some results?