ERROR (ProgrammingError) (2014, "Commands out of sync; you can't run this command now")

原创 2016年05月31日 17:06:29

错误场景:

使用Python开发的数据库升级工具,在升级脚本行遇到如下语句报错了:

DROP TRIGGER IF EXISTS acl_2_ael_insert;
CREATE TRIGGER acl_2_ael_insert AFTER INSERT ON alarmclientlog
FOR EACH ROW 
UPDATE alarmeventlog SET alarm_deal_type = new.alarm_deal_type 
    WHERE alarmeventlog.strIndex = new.strIndex 
        AND alarmeventlog.strUniqueTime = new.strUniqueTime;

先解释下这段语句,alarmeventlog 表示原始报警日志,alarmclientlog 表示报警处理日志。当alarmclientlog 插入或更新后,要把处理结果也同步到alarmeventlog 里面去。
因此,我创建一个触发器做同步操作,为防止之前已经有此触发器,我先检查并删除下。


问题定位:

在网上搜到如下有用的资料:

Python’s MySQLdb 2014 Error – Commands out of sync
这里面说可能跟多条语句放在一起执行有关。

但是有些语句是可以放在一起执行的,那是不是对SQL语句的类型由要求?
然后我找到了这个帖子,是创建存储过程时发现的:
Python, “commands out of sync; you can’t run this command now”

这位也一样:
解决error:2014 Commands out of sync; you can’t run this command now

其他错误:
2014 - Commands out of sync; you can’t run this command now


解决问题:

综上所述,我感觉触发器、存储过程、SHOW等命令语句不能放一起执行。【待查】

解决方案是把语句分开执行。

在MySQL的官网手册,我发现了这个问题的说明:

B.5.2.14 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.

网址:B.5.2.14 Commands out of sync

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

ERROR (ProgrammingError) (2014, "Commands out of sync; you can't run this command now")

错误场景:使用Python开发的数据库升级工具,在升级脚本行遇到如下语句报错了:DROP TRIGGER IF EXISTS acl_2_ael_insert; CREATE TRIGGER acl_...

PHP执行MYSQL存储过程报错:Commands out of sync; you can't run this command now 问题的解决

在PHP同一事物里调用MYSQL的存储过程后再次执行另外的一个或多个命令(或者在同一事物里执行多个存储过程),如果使用mysqli的query方法获得结果,将获得一个错误:Commands out o...

It seems that this file has not been built yet.Do you want to build it now? Codeblocks能构建build不能运run

安装codeblocks之后编写了一个简单程序不能运行,弹出提示框 It seems that this file has not been built yet.Do you want to bui...

MySQL CR_COMMANDS_OUT_OF_SYNC

mysql_error: commands out of sync; you can't run this command now.    why:    after you used 'mysq...

failed to sync branch You might need to open a shell and debug the state of this repo.

github同步失败

误用关键字-_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax;

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual t...

AS 2.0 开启Instant Run出现的问题:Error:Access to the dex task is now impossible, starting with 1.4.0

Error:Access to the dex task is now impossible, starting with 1.4.0 1.4.0 introduces a new Transform...

metasploit 中nessus nessus_connect问题:You must do this before any commands

新下载的kali2.0中metasploit默认有nessus插件,输入load nessus可以使用 输入nessus_help查看帮助 但是要用nessus插件需要用nessus_...

List of FTP commands for the Microsoft command-line FTP client

List of raw FTP commands (Warning: this is a technical document, not necessary for most FTP use.) ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)