_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操 ...
随机推荐
- 【Android】12.0 第12章 Intent及其过滤器—本章示例主界面
分类:C#.Android.VS2015: 创建日期:2016-02-23 一.简介 这一章我们主要学习Intent的基本用法,并通过例子演示如下功能: 如何启动另一个界面: 如何获取另一个界面的返回 ...
- 每日英语:Mooncake Austerity Hits China's Mid-Autumn Festival
First baijiu, then red carpets, and now mooncakes. For Chinese government officials, the list of tab ...
- 六、从length和length()方法开始
首先你可以快速回答下面问题吗.当没有任何IDE的情况下,如何得到一个数组的长度,如何得到一个String的长度.我问这个了很对不同水平的开发者:初级的中级的.他们不能快速正确的回答这个问题.当IDE提 ...
- How to add elements to a List in Scala
Scala List FAQ: How do I add elements to a Scala List? This is actually a trick question, because yo ...
- 【JavaFx】客户端服务器C/S架构搭建
客户端获取服务器端软件更新版本方法: package com.platform.ui.update; import java.io.BufferedInputStream; import java.i ...
- addEventListener()绑定事件的对象方法。
addEventListener()绑定事件的对象方法.addEventListener()含有三个参数,一个是事件名称,另一个是事件执行的函数,最后一个是事件捕获,, obj.addEventLis ...
- 模板方法模式(Head first 设计模式——7)
一.模板方法模式定义 模板方法模式:在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤. 从定义中,应该可以看出一部分,为 ...
- fullcalendar案例一<原>
fullcalendar是个很强大的日历控件,可以用它进行排班.排会议.拍任务,很直观,用户体验良好. 看下效果图: #parse("index/head.vm") <lin ...
- kafkaStream解析json出错导致程序中断的解决方法
出错在 KStreamFlatMapValues 方法执行时,由于json异常数据无法解析,结果生成的值为null,报错信息如下: 2018-04-18 19:21:04,776 ERROR [app ...
- 使用maven创建工程报错Could not resolve archetype org.apache.maven.archetype
错误: Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any ...