边学边用Mysql(3):cursor的一个bug
使用python连接mysql数据库时,如果遇到这样的错误提示:(2014, "Commands out of sync; you cant run this command now")可能是你的几条sql语句执行顺序有问题,也有可能是cursor本身的bug。在执行sql语句前最好清空 cursor里面的所有内容。def executeNonQuery(cursor, sql): whi
·
使用python连接mysql数据库时,如果遇到这样的错误提示:
(2014, "Commands out of sync; you can't run this command now")
可能是你的几条sql语句执行顺序有问题,也有可能是cursor本身的bug。
在执行sql语句前最好清空 cursor里面的所有内容。
def executeNonQuery(cursor, sql):
while cursor.nextset(): pass
cursor.execute(sql)
这样就没有问题了
(2014, "Commands out of sync; you can't run this command now")
可能是你的几条sql语句执行顺序有问题,也有可能是cursor本身的bug。
在执行sql语句前最好清空 cursor里面的所有内容。
def executeNonQuery(cursor, sql):
while cursor.nextset(): pass
cursor.execute(sql)
这样就没有问题了
更多推荐




所有评论(0)