How to disable database lock in sqlite with python

multi-threadpythonsqlite

I made a application in python and it should read and write simultaneously in multiple instances(multi CMD widows)(multi-threading). each thread is configured independently so it will not change the data that written with other instances. so in action app instance 1 will work with John's data and app instance 2 will work with Jane's data and so On.

the application concept is simple enough but in action when running multiple instances at once, there may be a situation that I get database locked error and the app will stop working.

I want to disable this locking system, because its not necessary in my application, I designed it Independent just for this reason.

can anybody tell me to do it in python? is it possible? where should I place a code or sql command or anything?

Best Answer

Using embedded sqlite is good for developing and testing, and I'm assuming you are using db like this:

db = sqlite3.connect('data/mydb')

In this case you could use several db like mydb1, mydb2 and so on. It would prevent the lockdown but overall it's not the solution.

I would suggest using several tables in single database instance via any RDS service you find appropriate. For example this one

Another solution could be moving from relational database to NoSQL solution. It would completely prevent the lockdown situation and it's highly scalable and affordable when data exchange volumes are relatively low.