omnilib/aiosqlite

AttributeError: 'Connection' object has no attribute '_tx'

hellocoldworld opened this issue · 1 comments

Description

Using executemany raises an error where traditional sqlite3 succeeds.

AttributeError: 'Connection' object has no attribute '_tx'. Did you mean: 'tx'?

Sample code with sqlite3

with sqlite3.connect("file::memory:?cache=shared", uri=True) as conn:
    cursor = conn.cursor()
    results = cursor.execute(
        """CREATE VIRTUAL TABLE IF NOT EXISTS test USING fts5(
            name,
            code UNINDEXED,
            tokenize="trigram"
        );
        """
    )
    cursor.executemany("INSERT INTO test VALUES (?, ?)", [("hello", 1), ("wo
rld", 2)])

With aiosqlite

async with aiosqlite.connect("file::memory:?cache=shared", uri=True) as conn:
    cursor = await conn.cursor()
    results = await cursor.execute(
        """CREATE VIRTUAL TABLE IF NOT EXISTS test USING fts5(
            name,
            code UNINDEXED,
            tokenize="trigram"
        );
        """
    )
    await cursor.executemany("INSERT INTO test VALUES (?, ?)", [("hello", 1), ("worlds", 1)])

Details

  • OS: MacOS X Monterey
  • Python version: python 3.10.4
  • aiosqlite version: 0.17.0
  • Can you repro on 'main' branch? Not tested (yet)
  • Can you repro in a clean virtualenv? Not tested (yet)

Sorry, I forgot to stash changes before testing 🤦