From e9952c026ccfb7194273a47eb23884f54235a460 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Feb 2021 15:21:03 -0500 Subject: [PATCH] Support subclassing Connection Add `cls` kwarg to `core.connect` that is a subclass or Connection (or a `Callable[[Callable[[Any], sqlite3.Connection], int], Connection]`) (default: `Connection`) --- aiosqlite/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aiosqlite/core.py b/aiosqlite/core.py index dfb98b9..836ec4e 100644 --- a/aiosqlite/core.py +++ b/aiosqlite/core.py @@ -376,6 +376,7 @@ def connect( *, iter_chunk_size=64, loop: Optional[asyncio.AbstractEventLoop] = None, + cls: Type[Connection] = Connection, **kwargs: Any ) -> Connection: """Create and return a connection proxy to the sqlite database.""" @@ -396,4 +397,4 @@ def connector() -> sqlite3.Connection: return sqlite3.connect(loc, **kwargs) - return Connection(connector, iter_chunk_size) + return cls(connector, iter_chunk_size)