Skip to content

Python 2.0: con.sql() fails while CONNECT-ed, and the Arrow error recommends the failing path #716

Open

Description

@yan-hic

What happens?

After CONNECT to a Quack server, con.sql(query) raises materialize() is not available while CONNECT-ed, even for a synthetic SELECT with no table references. The same query succeeds through con.execute(query).fetchall() and .fetchdf().

DB-API Arrow conversion also fails. Its error recommends con.sql(query).to_arrow_table() or .to_arrow_reader(), but con.sql(query) itself raises the first error, so the suggested alternative cannot be used on this installation.

This prevents clients built on DuckDB's relational API, including marimo SQL cells, from using CONNECT sessions. The failure reproduces without marimo.

To Reproduce

import duckdb

con = duckdb.connect()
con.execute("LOAD quack")
con.execute("ATTACH 'quack:YOUR_SERVER:9494' AS remote")
con.execute("CONNECT remote")

query = """
SELECT 42 AS n,
       1.23::DECIMAL(10,2) AS amount,
       DATE '2026-10-23' AS day,
       NULL::INTEGER AS empty
"""

print(con.execute(query).fetchall())  # Works
con.sql(query)                       # Raises before any conversion

Invalid Input Error: materialize() is not available while CONNECT-ed; DISCONNECT first

On the connected session, test these independently after handling the preceding exception:

con.execute(query).to_arrow_table()
con.execute(query).to_arrow_reader()

Both raise:
Invalid Input Error: Arrow output on a DB-API result is not available while CONNECT-ed; DISCONNECT first, or use con.sql(query).to_arrow_table() or to_arrow_reader()

OS:

linux aarch64

DuckDB Package Version:

2.0.0

Python Version:

3.14.4

Full Name:

Yannick Einsweiler

Affiliation:

hintsight

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration to reproduce the issue?

  • Yes, I have
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions