0
点赞
收藏
分享

微信扫一扫

django 更新数据库报错: Lost connection to MySQL server during query

背景:

在用django执行长时间任务时,最终结果更新数据库时报错

参考解决方法:

​​https://blog.csdn.net/xin_feng_08/article/details/114662882​​

在最终更新数据库之前,清理失效连接,重新获取,即可解决

from django.db import close_old_connections

close_old_connections()
launchobj = LaunchJob.objects.get(ids=launchjob_id)
launchobj.status = "SUCCESS"
launchobj.save()


举报

相关推荐

0 条评论