this is a general question: I'm using an sqlite3 DB and running a python program that changes, reads and writes to that DB.
I'm running the following command:
SELECT COUNT(*) FROM table WHERE prm1='a' AND prm2='b' prm3=12345;
When I run it regularly, it results the correct answer.
But when I run it multithreaded-ly, it results with different answers (sometimes it's correct, but sometimes wrong). Just for clarification: No write is being done in the meantime.
Are there any problems with running SQL commands simultaniously that I'm unaware of?
CodePudding user response:
The solution, as AlexK mentioned is that when using multithreading and querying the SQL table, you CANNOT use the same connection and need to open a new connection per each thread.
Hope this helps someone, I've been stuck on this for too long.