我有一小段Python代码,用于查询mySQL。
while True:
print "running SQL query"
cursor.execute('select * from sites where stage="NEW"')
results = cursor.fetchall() #Fetch results
for row in results:
print "change detected" #simplified line for testing
print "sleeping"
sleep(10)
当没有匹配的记录时,输出是 。
running SQL query
sleeping
running SQL query
sleeping
手动创建将匹配的SQL记录(允许循环重复的时间),输出仍然是:
running SQL query
sleeping
running SQL query
sleeping
停止脚本并重新启动,测试输出与预期一致。
running SQL query
change detected
sleeping
那么,结果是被缓存了吗?还是查询没有被重新运行?