Skip to content

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

Description

@kattassen

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

  • OS: Linux (6.2.0)
  • Python version: 3.11.6
  • aiosqlite version: 0.20.0 (latest pip install?)
  • Can you repro on 'main' branch? Have not tried
  • Can you repro in a clean virtualenv? Yes (running unitests with tox)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions