Sqlite python sqlite3.OperationalError: database is locked

前端 未结 4 1077
野的像风
野的像风 2020-12-17 17:45

I have written the following code, which is showing the sqlite3.OperationalError: database is locked error. Any help to debug would be much appreciated.

4条回答
  •  执笔经年
    2020-12-17 18:32

    I'm not sure if this will help anyone, but I figured out a solution to my own Locked Database problem.

    I use PyCharm and found that several instances of the script I was working on were all running. This was usually due to errors in the code I was testing, but it stayed active (and therefore the connection to the db was still active). Close out of those (stop all the processes) and try again - it has worked every time for me!

    If anyone knows a way to make it timeout after a little while, please comment this solution. I tried cur.execute("PRAGMA busy_timeout = 30000") (found from another thread on a similar question) but it didn't seem to do anything.

提交回复
热议问题