In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to realize the automatic reconnection of django database. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Automatically reconnect to the database when the Django database connection exceeds wait_timeout and the connection is lost.
Https://github.com/zhanghaofe...
Installation
Pip install django_db_reconnect
Note that only pymysql is supported. For django to use pymysql, you need to install the package first and add the following code to _ _ init__.py in the directory where settings.py resides:
Import pymysqlpymysql.install_as_MySQLdb ()
Use
Add django_db_reconnect to settings.py 's INSTALLED_APPS
INSTALLED_APPS = (# omit other configurations' django_db_reconnect',)
Other questions
Transactions or other autocommit=False non-autocommit situations will not automatically reconnect, otherwise writes before connection loss may result in no commit being discarded
On the django database automatic reconnection method to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.