Alternative for django.db.close_connection()

2019-07-17 05:01发布

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条回答
成全新的幸福
2楼-- · 2019-07-17 05:58

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.

查看更多
登录 后发表回答