Hello @Anaisdg
When i log in on InfluxDB Cloud and select Query Data and then view guide (application code, python), there is a tutorial and i more or less copy pasted code from there.
These blocks run just fine:
import os, time
from influxdb_client_3 import InfluxDBClient3, Point
host = “https://eu-central-1-1.aws.cloud2.influxdata.com”
client = InfluxDBClient3(host=host, token=my_token, org=my_organisation)
data = {
“point1”: {
“location”: “Klamath”,
“species”: “bees”,
“count”: 23,
},
“point2”: {
“location”: “Portland”,
“species”: “ants”,
“count”: 30,
},
“point3”: {
“location”: “Klamath”,
“species”: “bees”,
“count”: 28,
},
“point4”: {
“location”: “Portland”,
“species”: “ants”,
“count”: 32,
},
“point5”: {
“location”: “Klamath”,
“species”: “bees”,
“count”: 29,
},
“point6”: {
“location”: “Portland”,
“species”: “ants”,
“count”: 40,
},
}
for key in data:
point = (
Point(“census”)
.tag(“location”, data[key][“location”])
.field(data[key][“species”], data[key][“count”])
)
client.write(database=my_database, record=point)
time.sleep(1) # separate points by 1 second
print(“Complete. Return to the InfluxDB UI.”)
I get a message on the website that the database receives data.
the following block doesn’t work:
query = “”“SELECT *
FROM ‘census’
“””
table = client.query(query=query, database=my_database, language=‘sql’)
df = table.to_pandas().sort_values(by=“time”)
print(df)
error_message:
{
“name”: “FlightUnavailableError”,
“message”: “Flight returned unavailable error, with message: empty address list: . gRPC client debug context: UNKNOWN:empty address list: {grpc_status:14, created_time:"2024-05-05T13:09:44.314680034+00:00"}. Client context: IOError: Server never sent a data message. Detail: Internal”,
“stack”: "---------------------------------------------------------------------------
FlightUnavailableError Traceback (most recent call last)
Cell In[3], line 6
1 query = """SELECT *
2 FROM ‘census’
3 """
5 # Execute the query
----> 6 table = client.query(query=query, database=my_database, language=‘sql’)
8 # Convert to dataframe
9 df = table.to_pandas().sort_values(by="time")
File c:\Users\Cyrill\anaconda3\envs\ada\lib\site-packages\influxdb_client_3\init.py:257, in InfluxDBClient3.query(self, query, language, mode, database, **kwargs)
255 return mode_func() if callable(mode_func) else mode_func
256 except Exception as e:
→ 257 raise e
File c:\Users\Cyrill\anaconda3\envs\ada\lib\site-packages\influxdb_client_3\init.py:243, in InfluxDBClient3.query(self, query, language, mode, database, **kwargs)
241 ticket_data = {"database": database, "sql_query": query, "query_type": language}
242 ticket = Ticket(json.dumps(ticket_data).encode(‘utf-8’))
→ 243 flight_reader = self._flight_client.do_get(ticket, _options)
245 mode_func = {
246 "all": flight_reader.read_all,
247 "pandas": flight_reader.read_pandas,
(…)
252
253 }.get(mode, flight_reader.read_all)
255 return mode_func() if callable(mode_func) else mode_func
File c:\Users\Cyrill\anaconda3\envs\ada\lib\site-packages\pyarrow\_flight.pyx:1633, in pyarrow._flight.FlightClient.do_get()
File c:\Users\Cyrill\anaconda3\envs\ada\lib\site-packages\pyarrow\_flight.pyx:68, in pyarrow._flight.check_flight_status()
FlightUnavailableError: Flight returned unavailable error, with message: empty address list: . gRPC client debug context: UNKNOWN:empty address list: {grpc_status:14, created_time:"2024-05-05T13:09:44.314680034+00:00"}. Client context: IOError: Server never sent a data message. Detail: Internal"
}