python - Not able to get latest rows when re-rerunning same query at regular interval -


i using python mysqldb module. querying table every 1 seconds. new rows being added table time. code follows;

def main():      connectmysqldb_tagem()      while true:         querytable()         time.sleep(1)          closedbconnection()    

the problem code query not return latest rows. return same rows. solve problem, have close mysql connection , make new mysql connection everytime. workable code looks this;

def main():       while true:         connectmysqldb_tagem()         querytable()         closedbconnection()          time.sleep(1) 

how can avoid making new connection everytime in order latest rows?

pass sql_no_cache in select query, or turn off on session level:

cursor.execute("set session query_cache_type = off") 

see also:

hope helps.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -