Skip to content

Commit 501c0d3

Browse files
Accept max_total_rows on Connection / AsyncConnection
Cycle 9 — DBAPI Connection / AsyncConnection now take max_total_rows and thread it down to the underlying DqliteConnection, so SQLAlchemy (or any direct DBAPI user) can tune the cumulative row cap without reaching into private internals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 723585f commit 501c0d3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/dqlitedbapi/aio/connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ def __init__(
1717
*,
1818
database: str = "default",
1919
timeout: float = 10.0,
20+
max_total_rows: int | None = 10_000_000,
2021
) -> None:
2122
"""Initialize connection (does not connect yet).
2223
2324
Args:
2425
address: Node address in "host:port" format
2526
database: Database name to open
2627
timeout: Connection timeout in seconds (positive, finite)
28+
max_total_rows: Cumulative row cap across continuation
29+
frames. Forwarded to the underlying DqliteConnection;
30+
``None`` disables the cap.
2731
"""
2832
import math
2933

@@ -32,6 +36,7 @@ def __init__(
3236
self._address = address
3337
self._database = database
3438
self._timeout = timeout
39+
self._max_total_rows = max_total_rows
3540
self._async_conn: DqliteConnection | None = None
3641
self._closed = False
3742
# asyncio primitives MUST be created inside the loop they will
@@ -68,6 +73,7 @@ async def _ensure_connection(self) -> DqliteConnection:
6873
self._address,
6974
database=self._database,
7075
timeout=self._timeout,
76+
max_total_rows=self._max_total_rows,
7177
)
7278
try:
7379
await conn.connect()

src/dqlitedbapi/connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(
6464
*,
6565
database: str = "default",
6666
timeout: float = 10.0,
67+
max_total_rows: int | None = 10_000_000,
6768
) -> None:
6869
"""Initialize connection (does not connect yet).
6970
@@ -74,6 +75,9 @@ def __init__(
7475
and finite; validated here so direct ``Connection(...)``
7576
calls don't silently accept bad values that later
7677
produce hangs or stranger downstream errors)
78+
max_total_rows: Cumulative row cap across continuation
79+
frames for a single query. Forwarded to the underlying
80+
:class:`DqliteConnection`. ``None`` disables the cap.
7781
"""
7882
import math
7983

@@ -82,6 +86,7 @@ def __init__(
8286
self._address = address
8387
self._database = database
8488
self._timeout = timeout
89+
self._max_total_rows = max_total_rows
8590
self._async_conn: DqliteConnection | None = None
8691
self._closed = False
8792
self._loop: asyncio.AbstractEventLoop | None = None
@@ -193,6 +198,7 @@ async def _get_async_connection(self) -> DqliteConnection:
193198
self._address,
194199
database=self._database,
195200
timeout=self._timeout,
201+
max_total_rows=self._max_total_rows,
196202
)
197203
try:
198204
await conn.connect()

0 commit comments

Comments
 (0)