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:
- how turn off mysql query cache while using sqlalchemy?
- mysql - force not use cache testing speed of query
hope helps.
Comments
Post a Comment