omnilib / aiosqlite

asyncio bridge to the standard sqlite3 module
https://aiosqlite.omnilib.dev
MIT License
1.22k stars 94 forks source link

Connection received from cursor is not the created aiosqlite connection #285

Open kattassen opened 8 months ago

kattassen commented 8 months ago

Description

When fetching the connection from a cursor it responds with the underlaying sqlite3 connection instead of the aiosqlite. This makes the application crash with the following message if trying to run a commit on it: sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 139659649398464 and this is thread id 13...

    con = await aiosqlite.connect(":memory:")
    cur = await con.cursor()

    await con.commit()
    await cur.connection.commit()  # This row causes a crash since the connection fetched is not the created aiosqlite connection, but instead the underlaying sqlte3 connection

Details