aiosqlite icon indicating copy to clipboard operation
aiosqlite copied to clipboard

Support subclassing Connection

Open PikalaxALT opened this issue 4 years ago • 1 comments
trafficstars

Description

Add cls kwarg to core.connect that is a subclass or Connection (or a Callable[[Callable[[Any], sqlite3.Connection], int], Connection]) (default: Connection)

Example usage:

class MyConnection(aiosqlite.Connection):
    ...

async def main():
    conn = await aiosqlite.connect(':memory:', cls=MyConnection)
    # use methods and attrs of MyConnection

Current workaround: connect must be redefined to explicitly call your custom async connection factory.

PikalaxALT avatar Feb 22 '21 20:02 PikalaxALT

Sounds good. Can you add a simple test case covering this?

amyreese avatar Feb 23 '21 02:02 amyreese