Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python): Ensure that read_database takes advantage of Arrow return from a duckdb_engine connection when using a SQLAlchemy Selectable #19255

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions py-polars/polars/io/database/_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def _normalise_cursor(self, conn: Any) -> Cursor:
return conn.engine.raw_connection().cursor()
elif conn.engine.driver == "duckdb_engine":
self.driver_name = "duckdb"
return conn.engine.raw_connection().driver_connection
return conn
elif self._is_alchemy_engine(conn):
# note: if we create it, we can close it
self.can_close_cursor = True
Expand Down Expand Up @@ -505,8 +505,11 @@ def execute(
)
result = cursor_execute(query, *positional_options)

# note: some cursors execute in-place
# note: some cursors execute in-place, some access results via a property
result = self.cursor if result is None else result
if self.driver_name == "duckdb":
result = result.cursor

self.result = result
return self

Expand Down