Search code examples
databasepython-2.7sqlitetimeout

Error : Database is locked in sqlite3


I'm working on a python script where I'm connecting database of multiple server and executing the same query on all. Now, the issue is the database on some servers are locked, so need to understand how to unlock the same or if we can use timeout to skip few of the servers and run the query uninterrupted on remaining servers.


Solution

  • sqlite3.connect() has a timeout parameter (in seconds).

    But I recommend to change database to a client-server solution. SQLite is ok to handle large database for single program, but it's not very good at handling concurrent access from multiple programs. MySQL or Postgres will suite you much better.