pola-rs/polars · error · ValueError
only a single SQL query string is accepted for adbc, got a
Error message
only a single SQL query string is accepted for adbc, got a {qualified_type_name(query)!r} type What it means
The adbc engine can execute only a single SQL statement per call, so `read_database_uri` validates that `query` is a plain str when engine="adbc"; passing a list of queries (or any non-string) raises ValueError.
Solutions
- Call read_database_uri once per query string in your own loop.
- Use engine="connectorx" if you genuinely need multiple queries (it accepts a list).
- Combine multiple SELECTs into one statement if the database supports it.
Example fix
// before
pl.read_database_uri([q1, q2], uri, engine="adbc") # raises
// after
for q in (q1, q2):
df = pl.read_database_uri(q, uri, engine="adbc") Defensive patterns
Strategy: validation
Validate before calling
if engine == "adbc" and not isinstance(query, str):
raise ValueError("adbc accepts a single query string; loop over a list yourself") Type guard
def is_single_query(q) -> bool:
return isinstance(q, str) Try / catch
queries = [query] if isinstance(query, str) else query
if engine == "adbc":
dfs = [pl.read_database_uri(q, uri, engine="adbc") for q in queries]
else:
dfs = [pl.read_database_uri(query, uri, engine=engine)] Prevention
- Normalize query input to a list of strings in your own wrapper, then branch per engine
- Only pass lists of queries to the connectorx engine
- Unit-test engine/query-shape combinations in CI
When it happens
Trigger: Calling `read_database_uri(["SELECT ...", "SELECT ..."], uri, engine="adbc")` or passing a non-string query with the adbc engine.
Common situations: Reusing list-of-queries code written for the connectorx engine (which accepts lists); batch-running multiple statements in one call.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- `compat_level` has invalid type
- invalid plan stage
- `limit` cannot be None. If you want to show the complete…
- `offset` input for `with_row_index` cannot be
- 'pre_execution_query' is only supported in connectorx…
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/41f3b153bc258e2c.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/database/functions.py:521
raise ValueError(msg)
if pre_execution_query:
issue_unstable_warning(
"the 'pre-execution-query' parameter is considered unstable."
)
return _read_sql_connectorx(
query,
connection_uri=uri,
partition_on=partition_on,
partition_range=partition_range,
partition_num=partition_num,
protocol=protocol,
schema_overrides=schema_overrides,
pre_execution_query=pre_execution_query,
)
elif engine == "adbc":
if not isinstance(query, str):
msg = f"only a single SQL query string is accepted for adbc, got a {qualified_type_name(query)!r} type"
raise ValueError(msg)
if pre_execution_query:
msg = "the 'adbc' engine does not support use of `pre_execution_query`"
raise ValueError(msg)
return _read_sql_adbc(
query,
connection_uri=uri,
schema_overrides=schema_overrides,
execute_options=execute_options,
)
else:
msg = f"engine must be one of {{'connectorx', 'adbc'}}, got {engine!r}"
raise ValueError(msg)
View on GitHub (pinned to fe841f959e)