Python mysql查询问题

stranger_j 2017-09-08 06:15:30
运行同一个脚本 有时候运行正常,有时候运行报错
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run
this command now")
...全文
108 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
stranger_j 2017-09-09
  • 打赏
  • 举报
回复
引用 1 楼 xpresslink 的回复:
Mysql文档中说明错误:Commands out of sync If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order. This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between. 如果你正在使用mysql_use_result()并且在你已经调用了mysql_free_result()之前试图执行新查询。 如果你在mysql_use_result()或mysql_store_result()之间试图执行返回数据的2个查询,它也可能发生。 解决方法就是,检查一下你的脚本中有没有query结果大于1,却用了fetchone的情况。 都改用fetchall是一下。
查过了 都是用的fetchall
混沌鳄鱼 2017-09-08
  • 打赏
  • 举报
回复
Mysql文档中说明错误:Commands out of sync If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order. This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between. 如果你正在使用mysql_use_result()并且在你已经调用了mysql_free_result()之前试图执行新查询。 如果你在mysql_use_result()或mysql_store_result()之间试图执行返回数据的2个查询,它也可能发生。 解决方法就是,检查一下你的脚本中有没有query结果大于1,却用了fetchone的情况。 都改用fetchall是一下。

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧