I just can't figure out how to use the aiosqlite module so that I can keep the connection around for later use.
The example based on the aiosqlite project page
async with aiosqlite.connect('file.db') as conn:
cursor = await conn.execute("SELECT 42;")
rows = await cursor.fetchall()
print('rows %s' % rows)
works fine, but I want to keep the connection around so that I can use it throughout my program.
Typically, with sqlite, I open a connection, squirrel it away and then use it throughout the life of the program.
I also tried things like:
conn = aiosqlite.connect('file.db')
c = await conn.__enter__()
AttributeError: 'Connection' object has no attribute '__enter__'
Is there a way to use this module without a context manager?