aiosqlite
aiosqlite copied to clipboard
row_factory for Cursor is ignored
import asyncio
import aiosqlite
async def main():
async with aiosqlite.connect(":memory:") as db:
db.row_factory = aiosqlite.Row
async with await db.cursor() as cursor:
await cursor.execute("SELECT 1")
row = await cursor.fetchone()
print(type(row))
async with aiosqlite.connect(":memory:") as db:
db.row_factory = aiosqlite.Row
async with await db.cursor() as cursor:
cursor.row_factory = "I am teapot"
await cursor.execute("SELECT 1")
row = await cursor.fetchone()
print(type(row))
async with aiosqlite.connect(":memory:") as db:
db.row_factory = None
async with await db.cursor() as cursor:
cursor.row_factory = aiosqlite.Row
await cursor.execute("SELECT 1")
row = await cursor.fetchone()
print(type(row))
asyncio.run(main())
output
<class 'sqlite3.Row'>
<class 'sqlite3.Row'>
<class 'tuple'>
always uses row_factory from connection and ignore cursor row_factory