SQLite3 wrong values when multithreading
Question:
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?
Answers:
When using multithreading and querying the SQL table, you CANNOT use the same connection and need to open a new connection per each thread.
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?
When using multithreading and querying the SQL table, you CANNOT use the same connection and need to open a new connection per each thread.