_mysql_exceptions.ProgrammingError:(2014, "commands out of sync; you can't run this command now")
今天,测试dashboard上的一些graph, 发现,当多个graph同时向后台请求数据(异步)的时候, 出现了上述错误。而且,三个bug交替出现,另外两个bug分别是:python stop response 和mysql close closed connection。
查到最后,发现,因为ajax是异步请求的,而后台处理的时候,建立了一个connection以后,执行多条sql语句的时候,就出现了上述错误。
出错地方:

错误代码:
def ExceptionHandling_mysql(self,sql):
try:
cur = self.conn.cursor(libdb.cursors.DictCursor)
rowcount = cur.execute(sql)
self.conn.commit()
result = cur.fetchall()
while cur.nextset(): pass
#if cur:
#cur.close()
except Exception, e:
print 'This is mysql: %s' % (sql)
print e
result = [] #self.conn = libdb.connect(host=configeApp.getDBHost(), port=configeApp.getDBPort(), user=configeApp.getUserName(),
#passwd=configeApp.getPwd(), db=configeApp.getDBase(), use_unicode=True, charset='utf8')
if cur:
cur.close()
if self.conn:
self.conn.close()
return result
最终问题解决,改成一个connection,进行一个sql语句的查询。
_mysql_exceptions.ProgrammingError:(2014, "commands out of sync; you can't run this command now")的更多相关文章
- error:2014 Commands out of sync; you can't run this command now
如下错误: 分析原因: 前端ajax请求后台,共用同一个链接. 搜索别人的解决方案:http://blog.csdn.net/grass_ring/article/details/3499402 用m ...
- python mysql 2014 Commands out of sync; you can't run this command now
这个问题出现再 mysql和c 的api. 简单的解决方法是不使用api直接把整个连接和命令传过去. 例如,cmd = 'mysql -h 192.168.32.210 -P 3316 -u bfd ...
- 使用otl,报错:mysql Commands out of sync; you can't run this command now
1.代码如下: void TestCache(otl_connect& otlConn) { try { ] = {}; sprintf(sql,"call test1(1)&quo ...
- C mysql (C API Commands out of sync; you can't run this command now)
错误出现在当一个用户使用查询,另一个用户再使用此sql连接进行查询的时候: 原因是因为上一次使用此sql连接进行查询时没有将所有的结果集给释放掉,在所有使用此sql连接进行查询的地方将所有的结果集给释 ...
- mysql_query error:Commands out of sync;you can't run this command now
MYSQL_REST *result没有释放, 用mysql_free_result(result)即可.
- MySql: ”Commands out of sync“Error (Connect/C++)
使用 Connector/C++ 查询 Mysql , 连续调用存储过程时 会出现如下: Commands out of sync; you can't run this command now,st ...
- uWSGI 和 SQLAlchemy 一起使用的注意事项
最近在使用 Flask 中使用 SQLAlchemy 开发程序,一开始好好的,然后使用 uWSGI 部署到线上后,出现了各种 mysql 客户端的问题,如: (_mysql_exceptions.P ...
- python MySQLdb 一个连接connection多个cursor
使用MySQLdb时,如果创建一个连接connection,多个线程同时使用,会不会有问题? 在下文中,我们将模拟这种场景,看是否会出现问题. 1.示例 1.1 正常的情况 创建一个连接,两个线程同时 ...
- mysql错误之2014
error:2014 Commands out of sync; you can't run this command now 这个错误号我也真是醉了. 一直纠结于为什么存储过程执行完,commit操 ...
随机推荐
- tomcat在conf/Catalina/localhost目录下配置项目路径
转自:http://wangyl93-dl-cn.iteye.com/blog/1508517 在tomcat的conf/Catalina/localhost目录下配置项目路径,tomcat启动是会直 ...
- 学习笔记之gethostbyname函数
我们现在认知一台计算机主机通常采用直观可读的名字.例如博客园我们会记住 www.cnblogs.com 而不是记住42.121.252.58这个IP.对于大多数的应用程序来说应该是处理名字而不是处理地 ...
- winform TreeView 节点选择
public partial class Form1 : Form { public Form1() { InitializeComponent(); } string tag = "Tru ...
- python常用的十进制、16进制、字符串、字节串之间的转换
进行协议解析时,总是会遇到各种各样的数据转换的问题,从二进制到十进制,从字节串到整数等等 废话不多上,直接上例子 整数之间的进制转换: 10进制转16进制: hex(16) ==> 0x10 ...
- 关于 \t 水平制表符 Horizontal Tab (TAB)
今天在学learn python the hard way ex26修改的时候,有一个关于\t的问题,下面分别为代码以及输出结果: 1 poem = """ 2 \tTh ...
- 分享一个上传图片,图片压缩Unsupported Image Type解决方案
http://blog.csdn.net/frankcheng5143/article/details/53185201 *************************************** ...
- zookeeper连接 org.apache.curator.framework.imps.CuratorFrameworkImpl Background exception was not retry-able or retry gave up [main-EventThread]
ERROR org.apache.curator.framework.imps.CuratorFrameworkImpl Background exception was not retry-able ...
- Javascript中最常用的61个经典技巧[转]
1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu= ...
- Droptiles - 炫酷的 Metro 风格的层叠式 Web 面板
介绍 Droptiles是一套Metro风格的类似Win8的Web2.0控制面板.它采用图块(tiles)建立用户体验.图块(tiles)是一些可以从外部资源中获取数据的迷你应用.点击图块(tile) ...
- Qt学习之路(tip): parent参数
这是一篇很简单的文章,仅仅是用来说明一下一个参数的作用,因此我把它写成了tip,而不是接下来的17. 程序写的多了,你会发现几乎所有的Qt类的构造函数都会有一个parent参数.这个参数通常是QO ...