I have a class named 'DbWorker' to access data in SQlite DB. I design parallel procedure to create 3 cores by python multiprocessing. Each processors has 'DbWorker' object to process data and access DB.
Now I encountered a problem explained as follows:
time1: core-1: update data and insert them in DB
time2: core-2: look-up DB, but no data in DB
time3: core-3: the same problem as core-2
time4: core-1: look-up DB and DB has updated data
I found an article How to share a single SQLite connection in multi-threaded Python application. Then I used 'Lock' to avoid data competition, but nothing's happened.
Is there any way to solve this problem??
Eric
session.commit()aftersession.add(data)immediately.