django.db.close_connection()的替代方法 [英] Alternative for django.db.close_connection()

查看:726
本文介绍了django.db.close_connection()的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Django关闭后,是否有可能在MySQL中重新建立MySQL连接?

Is there a possible way to re-establish MySQL connection in Django after it goes down?

尝试使用django.core.wsgi中的get_wsgi_application访问MySQL时出现以下错误:

I am getting the following error while trying to access MySQL using the get_wsgi_application in django.core.wsgi:

(2006,'MYSQL server has gone away')

推荐答案

我们需要关闭Django之前自动创建的与db的旧连接.

We need to close the old connection to db, which Django had automatically created before.

我们可以通过执行以下功能来做到这一点:

We can do this by executing the function:

django.db.close_old_connections()

Django关闭先前的连接后会自动创建新的连接.

Django automatically creates new connections after closing previous connections.

这篇关于django.db.close_connection()的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆