Python/SQLite3: cannot commit - no transaction is active

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.


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.