# Python influxdb\_client\_3 query error (tutorial code)

**URL:** <https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129>\
**Category:** Systems\
**Tags:** influxdb, query, getting-started, python\
**Created:** [May 3, 2024, 3:02pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129 "2024-05-03T15:02:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyrillllll](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@Cyrillllll](https://community.influxdata.com/u/Cyrillllll)\
**Post date:** [May 3, 2024, 3:02pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/1 "2024-05-03T15:02:56Z")

</div>

Hello,

When going through the python tutorial for influxdb3, the query function throws an error:

code:  
query = “”“SELECT \*  
FROM ‘census’  
“””  
table = client.query(query=query, database=“database\_name”, language=‘sql’)  
df = table.to\_pandas().sort\_values(by=“time”)  
print(df)

error for client.query:  
“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-03T13:21:43.074492532+00:00”}. Client context: IOError: Server never sent a data message. Detail: Internal”

I am using the code provided by the tutorial and writing data works.

Any help would be much appreciated!

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [May 3, 2024, 9:19pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/2 "2024-05-03T21:19:15Z")

</div>

Hello @Cyrillllll  
Can you please share your entire script?  
You also have excess quotes

> **[Python client library for InfluxDB v3 | InfluxDB Cloud Serverless Documentation](https://docs.influxdata.com/influxdb/cloud-serverless/reference/client-libraries/v3/python/#query-using-influxql)**
>
> The InfluxDB v3 influxdb3-python Python client library integrates with Python scripts and applications to write and query data stored in an InfluxDB Cloud Serverless bucket.

Thank you!

---

<div class="post-metadata">

**Author:** ![Cyrillllll](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@Cyrillllll](https://community.influxdata.com/u/Cyrillllll)\
**Post date:** [May 5, 2024, 1:25pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/3 "2024-05-05T13:25:01Z")

</div>

Hello @Anaisdg

When i log in on [InfluxDB Cloud](https://cloud2.influxdata.com/signup) 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](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"  
}

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [May 6, 2024, 10:32pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/4 "2024-05-06T22:32:02Z")

</div>

Hmm @Cyrillllll,  
Thats very odd that you’re able to write with the client and not query with it. The error suggests you’re having an initialization/connection issue with it.

You can also use the pandas mode to return dataframes 🙂

```auto
query = "SELECT * FROM census"
pd = client.query(query=query, mode="pandas")
# Print the pandas DataFrame formatted as a Markdown table.
print(pd)

```

Can you please try that?

---

<div class="post-metadata">

**Author:** ![Cyrillllll](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@Cyrillllll](https://community.influxdata.com/u/Cyrillllll)\
**Post date:** [May 7, 2024, 9:45am UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/5 "2024-05-07T09:45:08Z")

</div>

@Anaisdg Thanks for the answer! Unfortunately it gives the same error. Reinitiating the client object before querying does not help either.

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/1/19f0add2b3c2511ed8859c6919b14f6b8db4b29c.png)

In the InfluxDBClient3 class (client) of the file called “ **init**.py” , the query method is defined and the last line of this block in the method doesn’t work:

```
        ticket_data = {"database": database, "sql_query": query, "query_type": language}
        ticket = Ticket(json.dumps(ticket_data).encode('utf-8'))
        flight_reader = self._flight_client.do_get(ticket, _options)

```

So i’m guessing it has to do with the connection to the database? Is there something i need to change in the settings on the cloud-website?

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [May 8, 2024, 5:49pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/6 "2024-05-08T17:49:47Z")

</div>

Yes I’d verify your host, token and org first.

This is working for me:

```import
from influxdb_client_3 import InfluxDBClient3, Point

token = "xxx"
org = "xxx"
host = "https://us-east-1-1.aws.cloud2.influxdata.com/"
database = "test"

client = InfluxDBClient3(
    token=token,
    host=host,
    org=org,
    database=database)

points = [
    Point("home")
            .tag("room", "Kitchen")
            .field("temp", 25.3)
            .field('hum', 20.2)
            .field('co', 9),
    Point("home")
            .tag("room", "Living Room")
            .field("temp", 24.0)
            .field('hum', 20.0)
            .field('co', 5)]

client.write(record=points)
sql = '''Select * from home'''
table = client.query(query=sql, language='sql', mode='pandas')
print(table)

```

---

<div class="post-metadata">

**Author:** ![Cyrillllll](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@Cyrillllll](https://community.influxdata.com/u/Cyrillllll)\
**Post date:** [May 13, 2024, 8:32am UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/7 "2024-05-13T08:32:03Z")

</div>

@Anaisdg Hi, I created a new all access token and verified host and organization but the query method still doesn’t work. I copied your code and it runs fine until client.query() and then outputs the same error as before. I tried out the inlfuxdb2 library and that one works for the same token, host and org.

---

<div class="post-metadata">

**Author:** ![pattern](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@pattern](https://community.influxdata.com/u/pattern)\
**Post date:** [June 23, 2024, 2:37am UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/8 "2024-06-23T02:37:34Z")

</div>

I’m noticing exactly the same error as OP.

---

<div class="post-metadata">

**Author:** ![kgmuzu](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/kgmuzu/32/15333_2.png) [@kgmuzu](https://community.influxdata.com/u/kgmuzu)\
**Post date:** [July 26, 2024, 3:45pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/9 "2024-07-26T15:45:28Z")

</div>

just copied pasted all the python code and I get the same error

---

<div class="post-metadata">

**Author:** ![stewart](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/stewart/32/16062_2.png) [@stewart](https://community.influxdata.com/u/stewart)\
**Post date:** [August 1, 2024, 2:52pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/10 "2024-08-01T14:52:57Z")

</div>

I’m also experiencing this issue

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [August 1, 2024, 7:41pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/11 "2024-08-01T19:41:10Z")

</div>

Hello @kgmuzu @stewart and @pattern,  
I have made an issue here:

> <https://github.com/InfluxCommunity/influxdb3-python/issues/102>
>
> \### Specifications
> 
> \* Client Version: v3
> \* InfluxDB Version: Cloud 3
> 
> This is… from this community question: 
> https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/8
> 
> 
> \### Code sample to reproduce problem
> 
> \`\`\`python
> 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.”)
> 
> query = “”“SELECT \*
> FROM ‘census’
> “””
> 
> table = client.query(query=query, database=my\_database, language=‘sql’)
> df = table.to\_pandas().sort\_values(by=“time”)
> print(df)
> \`\`\`
> 
> 
> \### Expected behavior
> 
> Return results. Thank you! 
> 
> \### Actual behavior
> 
> {
> “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
> 
> \### Additional info
> 
> \_No response\_

Please comment on the issue.

---

<div class="post-metadata">

**Author:** ![bednar](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/bednar/32/3690_2.png) [@bednar](https://community.influxdata.com/u/bednar)\
**Post date:** [August 6, 2024, 4:16am UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/12 "2024-08-06T04:16:22Z")

</div>

The issue was caused by using the `influxdb_client_3` with an InfluxDB 2 account. This client is specifically designed to support only InfluxDB 3.

---

<div class="post-metadata">

**Author:** ![max.schwendeler](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@max.schwendeler](https://community.influxdata.com/u/max.schwendeler)\
**Post date:** [August 8, 2024, 9:32am UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/13 "2024-08-08T09:32:18Z")

</div>

How are we able to evalute the influxdb\_cilient\_3 as a not yet customer? Is there an option to sign up for a InfluxDB 3 account?

---

<div class="post-metadata">

**Author:** ![jm\_wingdm](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@jm\_wingdm](https://community.influxdata.com/u/jm_wingdm)\
**Post date:** [March 24, 2025, 12:41pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/14 "2025-03-24T12:41:57Z")

</div>

I am running into this same problem while trying to query data from an Influxdb v2 instance which is running locally in a docker container in my laptop, using the influxdb3-client python library.  
The purpose of my tests is the recent (as of March 2025) announcement of InfluxQL being favored instead of Flux.  
Currently, InfluxDB v3 is not in a state ready for production, so we want to keep using v2 until then, but we’d like to use InfluxQL now and avoid further re-coding in the future.  
Recommendation says to use the v3 library, but I have not been able to pass this hurdle yet.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [March 25, 2025, 4:46pm UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/15 "2025-03-25T16:46:41Z")

</div>

> [@bednar](#):
>
> This client is specifically designed to support only InfluxDB 3.

Please see ^that response.  
You can query v2 with influxql but it takes a lot of setup. Honestly might be harder than just continuing to query in flux and then changing your queries to influxql with GA.

> **[Query data with InfluxQL | InfluxDB OSS v2 Documentation](https://docs.influxdata.com/influxdb/v2/query-data/influxql/)**
>
> Use the InfluxDB 1.x /query compatibility endpoint to query data in InfluxDB Cloud and InfluxDB OSS 2.4 with InfluxQL.

It also doesn’t support all influxql queries…

---

<div class="post-metadata">

**Author:** ![jm\_wingdm](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@jm\_wingdm](https://community.influxdata.com/u/jm_wingdm)\
**Post date:** [March 26, 2025, 9:19am UTC](https://community.influxdata.com/t/python-influxdb-client-3-query-error-tutorial-code/34129/16 "2025-03-26T09:19:35Z")

</div>

Thanks Anais, I guess it’s top secret, but is there a rough timeline of when will v3 ready for production?
