Skip to content

Commit

Permalink
fix(python): Ensure that read_database takes advantage of Arrow ret…
Browse files Browse the repository at this point in the history
…urn from a `duckdb_engine` connection when using a SQLAlchemy `Selectable` (#19255)
  • Loading branch information
alexander-beedie authored Oct 16, 2024
1 parent 3720494 commit 20ead46
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 20ead46

Please sign in to comment.