Skip to content Skip to sidebar Skip to footer

Python/SQLite3: Cannot Commit - No Transaction Is Active

I'm trying to code a book indexer using Python (traditional, 2.7) and SQLite (3). The code boils down to this sequence of SQL statements: 'select count(*) from tag_dict' () /* [(30

Solution 1:

Well, as it often happens I found the solution just a minutes after posing the question.

The solution was found here and consists of the only idea:

Never use BEGIN/COMMIT in non-autocommit mode in Python application - use db.commit() and db.rollback() only!

It sounds odd, but it works.


Solution 2:

This is a pretty late response, but perhaps take a look at APSW if you want finer-grain control over transactions. I ran a few tests on deferred transactions involving reads on pysqlite, and it just doesn't seem to perform correctly.


Solution 3:

cursor=connection.cursor()
cursor.executemany("insert into person(firstname, lastname) values (?, ?)", persons)
connection.commit()

Post a Comment for "Python/SQLite3: Cannot Commit - No Transaction Is Active"