Polars query to QuestDB results in "query is not allowed here"

Polars query to QuestDB results in "query is not allowed here"

What's the fastest way to query data?

Typically I would use polars to just read directly with zero copy through their ConnectorX engine

uri = "postgresql://username:password@server:port/database"
query = "SELECT * FROM foo"

pl.read_database_uri(query=query, uri=uri)

But this isn't working "db error: db error: ERROR: query is not allowed here"

It this because QuestDB doesn't support Arrow engines?

Answer

At the time of this answer, QuestDB does not support ADBC yet, but support is on the roadmap (it shows right now as expected for 2025 Q3 [1]).

Having said so, it is possible to use Polars with QuestDB, via sqlAlchemy connector.

import polars as pl
from sqlalchemy import create_engine

conn = create_engine(f"postgresql://admin:Read more:8812/qdb").connect()
query = "SHOW TABLES"
df=pl.read_database(query=query, connection=conn)
df.select(pl.col("table_name"))

That would connect to postgresql, and execute a query, returned as a polars dataframe. Of course in this case it would not be zero-copy, as data is sent using the postgresql-wire protocol and then transformed into the dataframe, but it works and once QuestDB supports ADBC it should be easy to replace in the code.

Screenshot of ipython showing the code in the snippet connecting to a QuestDB instance and returning some table names

[1] https://github.com/orgs/questdb/projects/1/views/5

Enjoyed this article?

Check out more content on our blog or follow us on social media.

Browse more articles