如何防止 pandas psql.read_sql_query 获取缓存 [英] how to prevent pandas psql.read_sql_query from fetching cache
问题描述
我使用 Pandas 0.15.2 并从 mysql 存储过程读取到数据帧
i use pandas 0.15.2 and read from a mysql storedproc into dataframe
import pandas.io.sql as psql
cnx= pymysql.connect( .. connection string ...)
df=psql.read_sql_query('call storedproc', con=cnx)
数据库非常活跃,经常有新数据,我意识到每当我重新运行上述语句将数据加载到我的数据帧中时,它都会返回最后查询的数据缓存.如果我再重新运行 read_sql_query 几次,它最终会被加载.我的问题是确保它永远不会获得以前缓存的数据的正确方法是什么?
the database is quite active with new data frequently, I realise whenever i rerun the above statements to load the data into my dataframe, it returns the last queried data cache. if i rerun the read_sql_query a few more times, it does get loaded eventually. My question is what is the right way to ensure it never get previously cached data?
推荐答案
经过一些测试,我在连接参数中添加了 autocomit=True 并且它停止获取缓存的结果集,即使我只是在执行读取操作.希望这对其他人有帮助.
after some testing, i added autocomit=True in the connection parameters and it stop fetching cached resultsets even if i am only doing a read. hope this help others.
这篇关于如何防止 pandas psql.read_sql_query 获取缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!