基于下面库进行优化,主要适配Django==5.0.3以后的版本。修复原子事务报错的问题
安装:pip install mysql_server_has_gone
因为代码里用到了MySQLdb库,所以需要安装mysqlclient。如果你用到了其他库导致报错,可以github上滴滴我,我会及时修复的。
以下是原始文档:
MySQL-server-has-gone-away
This repository solves issue where database connection inside of django overlives MySQL database connection timeout specified in /etc/my.cnf wait_timeout = xxxx. See this issue
How to use:
-
For Django 1.x and 2.x use
pip install mysql_server_has_gone_away==1.0.0 -
For django 3.x use
pip install mysql_server_has_gone==2.0.0 -
Put this engine into Django
settings.py:
DATABASES = {
'default': {
'ENGINE': 'mysql_server_has_gone_away',
#'NAME': 'database-name',
#'USER': 'database-user',
#'PASSWORD': 'database-password',
#'HOST': 'localhost',
}
}
Metadata
Release files for mysql-server-has-gone 2.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mysql_server_has_gone-2.0.5.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mysql_server_has_gone-2.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / mysql_server_has_gone-2.0.5.tar.gz
| Download URL | mysql_server_has_gone-2.0.5.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa95410580b4cae4f11a198e7999092e66a02b3ec67ff912e6f4572e190c35a3
|
|
BLAKE2b-256 checksum How to use checksums |
cd5680b4ba1e6fd0fc3b43bdb84df7c99a130cfc7dcd52fe92d12b332ec77716
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|
Release files / mysql_server_has_gone-2.0.5-py3-none-any.whl
| Download URL | mysql_server_has_gone-2.0.5-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12373228497b47c9283c8a78f295b481552a82247b0242fcd74d7dd673fe3b5d
|
|
BLAKE2b-256 checksum How to use checksums |
5c286f29a5f04e434902a4fa14aade1f96e45a62dc7ea40f8bd1e4556118a0f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|