A Django middleware and decorator to automatically handle database connection losses.
Project description
Django DB Reconnect
A simple Django app that provides a middleware and a decorator to automatically handle database connection losses (e.g., "MySQL server has gone away").
This utility catches specific OperationalError exceptions, closes the stale database connections, and retries the operation once. This can help improve the stability of long-running Django applications or applications with intermittent network access to the database.
Installation
pip install bear-django-query-profiler
Usage
- Add the middleware to your
MIDDLEWARElist insettings.py.
# settings.py
MIDDLEWARE = [
'db_reconnect.middleware.DBConnectionMiddleware',
]
- (Optional) You can override this list by defining DB_RECONNECT_ERROR_CODES in your settings.py.
# settings.py
DB_RECONNECT_ERROR_CODES = [2006, 2013]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bear_django_db_reconnect-0.1.0.tar.gz.
File metadata
- Download URL: bear_django_db_reconnect-0.1.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
730be896061ec98756349bd5f03a3b72d3b90d72d63cbdb1594a4703067e30b7
|
|
| MD5 |
7c6b7baa7f1c3c550db2d1d75714b412
|
|
| BLAKE2b-256 |
6b80e8c46edecf243bf140265986a9d6e25de4445170b0abdd0a0644d4720650
|
File details
Details for the file bear_django_db_reconnect-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bear_django_db_reconnect-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7a2549a90e2fc3e80a6a01fd876931eae02d99771097313b15870e641eee04f
|
|
| MD5 |
e25890487b11c4c403c2b08bc7e62154
|
|
| BLAKE2b-256 |
2f2349222533d59268d5bf08d974b83483a9cefacafa082d0bc0f3e1da25fdb9
|