Tune:
- Python A script inserts data into the database every 15 minutes
- Python B script retrieves the last few records from the database every few minutes
Both use Django ORM, run on the same computer, and use the local MySQL database.
This problem:
B retrieves records except the most recent, although A saves them minutes earlier.
I suspected that A did not close the transaction, so B sees the database without the last record. Indeed, while studying MySQL logs, I noticed that commit for each INSERT happens right before the next INSERT .
Although it should be redundant, I added the @commit_on_success decorator to function A, which includes save() , but that didn't help.
How can I get Django (or MySQL ?!) to commit right after save() ?
UPDATE:
I found that commits really happen - I mistakenly thought this was not the case, because MySQL General Query Log only has a resolution of 1 second .
In the light of this and other new information, I again asked a question here .
source share