Alternative for django.db.close_connection()

寵の児 提交于 2019-12-11 03:38:50

问题


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

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')

回答1:


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 automatically creates new connections after closing previous connections.



来源:https://stackoverflow.com/questions/45705509/alternative-for-django-db-close-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!