Skip to main content

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

  1. Add the middleware to your MIDDLEWARE list in settings.py.
# settings.py
MIDDLEWARE = [
    'db_reconnect.middleware.DBConnectionMiddleware',
]
  1. (Optional) You can override this list by defining DB_RECONNECT_ERROR_CODES in your settings.py.
# settings.py
DB_RECONNECT_ERROR_CODES = [2006, 2013]

Metadata

Release files for bear-django-db-reconnect 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bear-django-db-reconnect 0.1.0
File Size Uploaded Provenance Actions
bear_django_db_reconnect-0.1.0.tar.gz 2.5 kB Without provenance Details for bear_django_db_reconnect-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bear-django-db-reconnect 0.1.0
File Interpreter ABI Platform Actions
bear_django_db_reconnect-0.1.0-py3-none-any.whl Python 3 none any Details for bear_django_db_reconnect-0.1.0-py3-none-any.whl

Total release size: 5.9 kB

Release files / bear_django_db_reconnect-0.1.0.tar.gz

Download URL bear_django_db_reconnect-0.1.0.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
730be896061ec98756349bd5f03a3b72d3b90d72d63cbdb1594a4703067e30b7
BLAKE2b-256 checksum
How to use checksums
6b80e8c46edecf243bf140265986a9d6e25de4445170b0abdd0a0644d4720650
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / bear_django_db_reconnect-0.1.0-py3-none-any.whl

Download URL bear_django_db_reconnect-0.1.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7a2549a90e2fc3e80a6a01fd876931eae02d99771097313b15870e641eee04f
BLAKE2b-256 checksum
How to use checksums
2f2349222533d59268d5bf08d974b83483a9cefacafa082d0bc0f3e1da25fdb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Security for bear-django-db-reconnect 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page