I am using Python MySQLdb module. I am querying a table every 1 seconds. New rows are being added to this table all the time. The code is as follows;
def main():
connectMySqlDb_tagem()
while True:
queryTable()
time.sleep(1)
closeDBconnection()
The problem with the code is that the query does not return the latest rows. It always return the same rows. To solve this problem, I have to close the MySQL connection and make a new MySQL connection everytime. The workable code looks like this;
def main():
while True:
connectMySqlDb_tagem()
queryTable()
closeDBconnection()
time.sleep(1)
How can I avoid making a new connection everytime in order to get the latest rows?