本文主要是介绍pymysql报错: unable to rollback、Already closed,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考:
https://www.coder.work/article/4516746
https://www.cnblogs.com/leijiangtao/p/11882107.html
https://stackoverflow.com/questions/55116007/pymysql-query-unable-to-rollback
unable to rollback处理:
# 关闭光标对象
cursor.close()
# 关闭数据库连接
sql_connection.close()
注意:connection不要放到全局变量里。
Already closed处理
try:self.conn.ping(reconnect=True)print "db is connecting"
except:traceback.print_exc()self.conn = self.to_connect()print "db reconnect"
这篇关于pymysql报错: unable to rollback、Already closed的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!