urie
urie

Reputation: 371

SQLite3 wrong values when multithreading

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?

Upvotes: 0

Views: 60

Answers (1)

urie
urie

Reputation: 371

When using multithreading and querying the SQL table, you CANNOT use the same connection and need to open a new connection per each thread.

Upvotes: 1

Related Questions