<div dir="ltr"><div dir="ltr" class="gmail_msg">Hi Craig,<div class="gmail_msg"><br class="gmail_msg"></div></div><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><br class="gmail_msg">    cursor.execute(statement, parameters)<br class="gmail_msg">sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) cannot VACUUM from within a transaction [SQL: 'vacuum;']<br class="gmail_msg"><br class="gmail_msg">buildbot.test.unit.test_scripts_cleanupdb.TestCleanupDb.test_cleanup<br class="gmail_msg">-------------------------------------------------------------------------------<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I did some analysis, and found that the source of the problem is due to this</div><div class="gmail_msg">change in Python 3: <a href="https://docs.python.org/3/whatsnew/3.6.html#changes-in-the-python-api" class="gmail_msg" target="_blank">https://docs.python.org/3/whatsnew/3.6.html#changes-in-the-python-api</a>:</div><div class="gmail_msg"><br class="gmail_msg">* sqlite3 no longer implicitly commits an open transaction before DDL statements. </div></div></blockquote><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think the easiest way to fix this would be to enable auto-commit mode</div><div class="gmail_msg">for sqlite3, as was the previous default behavior in earlier versions of Python.</div></div></blockquote><div><br></div><div>Actually I think this is a bug. Every database transaction that start with transaction = conn.begin() should end with transaction.commit().</div><div>Also there is a need to close every query before starting another.</div><div>It often works if you don't but sometimes gives weird behavior (I am not sure exactly why), and its hard to track.</div><div><br></div><div>            res = conn.execute(q)</div><div>            [...]</div><div>            res.close()</div><div><br></div><div>Pierre</div></div></div>