>>> _cursor.execute("select * from bitter.test where id > 34") 1L >>> _cursor.fetchall() ({'priority': 1L, 'default': 0, 'id': 35L, 'name': 'chinanet'},) >>> _cursor.execute("select * from bitter.test where id > 34") 1L >>> _cursor.fetchall() ({'priority': 1L, 'default': 0, 'id': 35L, 'name': 'chinanet'},) >>>
第一次,我跑光标.执行以及游标.fetchall,我得到了正确的结果。在
在第二次运行execute和fetchall之前
我在mysql中插入id为36的数据,并在mysql中运行commit命令
但是cursor.execute/fetchall在没有新数据的情况下,不能只获取数据
我猜你在用InnoDB。这是InnoDB事务的默认值。在
我还没有测试过,但是通过在当前连接上发出
commit()
来强制MySQLdb启动一个新事务,或者创建一个新的连接,可能会解决这个问题。在我试了一下,结果就出来了
相关问题 更多 >
编程相关推荐