Database locked?
(1.1) By Leam (LeamHall) on 2022-01-15 21:46:33 edited from 1.0 [link] [source]
I'm running Python and the SQLite driver with some tests. One test does an insert, a select on "like", and then a delete of the row just inserted. The insert method executes the insert and then does a "con.commit()". If I put the test first in the test file, or run it by itself, it works fine. If I remove the "con.commit()", it works fine. Otherwise, if the test is run with the other tests, and has the con.commit(), and isn't the first test, it fails with a "Database locked" error. How do I ensure the database is unlocked as it goes from test to test? There are several other tests that impact the database, is this is the only one that chokes. Thanks! Leam ## Addendum ## Found out that the cursor can be opened and closed with each method. Implemented that, and the issue seems resolved.
(2) By Gunter Hick (gunter_hick) on 2022-01-17 15:38:11 in reply to 1.1 [source]
Your are not handling your transactions properly. Make sure to properly commit (or rollback) any transactions. Maybe your "Python SQLite driver" is second guessing (wrongly) when to begin and end transactions.