参考:
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处理:
bash
# 关闭光标对象
cursor.close()
# 关闭数据库连接
sql_connection.close()
注意:connection不要放到全局变量里。
Already closed处理
bash
try:
self.conn.ping(reconnect=True)
print "db is connecting"
except:
traceback.print_exc()
self.conn = self.to_connect()
print "db reconnect"