Skip to content

Commit 9bb9aee

Browse files
Add query_raw() method for DBAPI cursor integration
Add a public query_raw() method that returns (column_names, rows) through _run_protocol(), providing _in_use guard, connection invalidation on fatal errors, and leader-change detection. This gives the DBAPI cursor a proper public API to use instead of accessing _protocol directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a4d40f0 commit 9bb9aee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/dqliteclient/connection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ async def execute(self, sql: str, params: Sequence[Any] | None = None) -> tuple[
237237
"""
238238
return await self._run_protocol(lambda p, db: p.exec_sql(db, sql, params))
239239

240+
async def query_raw(
241+
self, sql: str, params: Sequence[Any] | None = None
242+
) -> tuple[list[str], list[list[Any]]]:
243+
"""Execute a query and return raw (column_names, rows).
244+
245+
Unlike fetch() which returns dicts, this returns the raw tuple
246+
of (column_names, rows) from the wire protocol. Intended for
247+
DBAPI cursor implementations that need column names separately.
248+
"""
249+
return await self._run_protocol(lambda p, db: p.query_sql(db, sql, params))
250+
240251
async def fetch(self, sql: str, params: Sequence[Any] | None = None) -> list[dict[str, Any]]:
241252
"""Execute a query and return results as list of dicts."""
242253
columns, rows = await self._run_protocol(lambda p, db: p.query_sql(db, sql, params))

0 commit comments

Comments
 (0)