[devel at bb.net] Request for Python 3 porting help: VACUUM and sqlite problem

Pierre Tardy tardyp at gmail.com
Wed Feb 1 08:56:08 UTC 2017


Hi Craig,


    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) cannot VACUUM
from within a transaction [SQL: 'vacuum;']

buildbot.test.unit.test_scripts_cleanupdb.TestCleanupDb.test_cleanup
-------------------------------------------------------------------------------


I did some analysis, and found that the source of the problem is due to this
change in Python 3:
https://docs.python.org/3/whatsnew/3.6.html#changes-in-the-python-api:

* sqlite3 no longer implicitly commits an open transaction before DDL
statements.


I think the easiest way to fix this would be to enable auto-commit mode
for sqlite3, as was the previous default behavior in earlier versions of
Python.


Actually I think this is a bug. Every database transaction that start with
transaction = conn.begin() should end with transaction.commit().
Also there is a need to close every query before starting another.
It often works if you don't but sometimes gives weird behavior (I am not
sure exactly why), and its hard to track.

            res = conn.execute(q)
            [...]
            res.close()

Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/devel/attachments/20170201/6235d3ca/attachment.html>


More information about the devel mailing list