【发布时间】:2009-10-24 10:43:14
【问题描述】:
我有一个脚本等待数据库中的某些行被更新:
con = MySQLdb.connect(server, user, pwd, db)
脚本启动时,该行的值为"running",并等待该值变为"finished"
while(True):
sql = '''select value from table where some_condition'''
cur = self.getCursor()
cur.execute(sql)
r = cur.fetchone()
cur.close()
res = r['value']
if res == 'finished':
break
print res
time.sleep(5)
当我运行这个脚本时,它会永远挂起。即使我在查询表时看到该行的值已更改为"finished",但脚本的打印输出仍然是"running"。
有没有我没有设置的设置?
编辑:python 脚本只查询表。表的更新是由一个 tomcat webapp 执行的,使用 JDBC,它是在 autocommit 上设置的。
【问题讨论】: