我在线部署时在我的Python Flask应用程序中出现此错误。它正在使用localhost但在CentOS服务器上出现此错误。
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync;
you can't run this command now") in <bound method DictCursor.__del__ of
<MySQLdb.cursors.DictCursor object at 0x1f7ead0>> ignored
我正在尝试循环运行此查询。
g.db.autocommit(True)
cur = g.db.cursor()
cur.execute("select * from users")
destinations = cur.fetchall()
destinations = [customer.copy() for customer in destinations]
for customer in destinations:
cur.execute('select SUM(minutes) as minutes from details where code=%s', (customer['id'],))
customer['minutes'] = cur.fetchone()
cur.execute('select start from details where code=%s order by id limit 1', (customer['id'],))
customer['start'] = cur.fetchone()
return json.dumps(destinations, cls=DateEncoder)