I have a strange behaviour on a current project. I use python3 and pymysql to connect to my DB. In my database i'm storing time interval in the form of table planning :
------------------------------
| id | start | end |
------------------------------
| 1 | time1 | time2 |
------------------------------
I have a thread loop which query every minute the database to select the interval with the next query :
SELECT * FROM `planning` WHERE `start` < 'current_timestamp' AND `end` > 'current_timestamp'
Ok here the problem : If the interval exists before i start the thread, the thread will select the interval correctly If the interval is created while the thread is already running, the thread will not select the interval, but if use the sql query in phpmyadmin for example i get the interval. Moreover if I stop the thread and restart it, the thread will select correctly the interval.
And I don't understand why the thread can't detect new interval in the db, if someone has any ideas ?
Learn about transactions and isolation levels.