{ "info": { "author": "Sector Labs", "author_email": "open-source@sectorlabs.ro", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5" ], "description": "# Django Database Connection Retrier\n\n[![License](https://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)\n[![PyPi](https://badge.fury.io/py/django-db-connection-retrier.svg)](https://pypi.python.org/pypi/django-db-connection-retrier)\n[![CircleCI](https://circleci.com/gh/SectorLabs/django-db-connection-retrier/tree/master.svg?style=svg&circle-token=8177e64d426308c93d38af49a1cca1df4225bc67)](https://circleci.com/gh/SectorLabs/django-db-connection-retrier/tree/master)\n\nAutomatically try to re-establish Django database connections when they fail due to DNS errors.\n\n---\n\nWhen the Django app (`dbconnectionretrier`) loads, a hook is installed in Django's [`BaseDatabaseWrapper.ensure_connection`](https://github.com/django/django/blob/master/django/db/backends/base/base.py#L216) that catches `django.db.OperationalError`. If the error raised is a DNS error, the connction attempt is retried synchronously **three times**.\n\n---\n\nTested on Django 2.0-2.3 and Python 3.7 and 3.8. Might work with other versions of Django and Python.\n\n## Installation\n1. Install the package from PyPi:\n\n $ pip install django-db-connection-retrier\n\n2. Add `dbconnectionretrier` to your `INSTALLED_APPS`:\n\n INSTALLED_APPS = [\n 'dbconnectionretrier',\n ...\n ]\n\n## Manual usage\nAdding `dbconnectionretrier` to `INSTALLED_APPS` enables automatic connection retrying. Want more granular control over patching?\n\n### Globally\n```\nfrom dbconnectionretrier.patch import patch_ensure_connection\n\n# after this line executes, connection retrying is enabled\npatch = patch_ensure_connection()\n\n# after this line, the connection retrying is disabled\npatch.rollback()\n```\n\n### Context manager\n```\nfrom dbconnectionretrier.patch import patch_ensure_connection_contextual\n\nwith patch_ensure_connection_contextual():\n # all code inside this block benefits from connection retrying\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SectorLabs/django-db-connection-retrier", "keywords": "django,postgres,extra,hstore,ltree", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-db-connection-retrier", "package_url": "https://pypi.org/project/django-db-connection-retrier/", "platform": "", "project_url": "https://pypi.org/project/django-db-connection-retrier/", "project_urls": { "Homepage": "https://github.com/SectorLabs/django-db-connection-retrier" }, "release_url": "https://pypi.org/project/django-db-connection-retrier/1.0b1/", "requires_dist": null, "requires_python": "", "summary": "Automatically ty re-establishing the Django database connection when it gets lost.", "version": "1.0b1" }, "last_serial": 5839761, "releases": { "1.0a2": [ { "comment_text": "", "digests": { "md5": "91f53afe7cda2ef33ca7b6cf0206f499", "sha256": "79afa9c647799f6dc39afcabb6edf7364f8989c86c2ff27ab79d5efbd04c7b70" }, "downloads": -1, "filename": "django-db-connection-retrier-1.0a2.tar.gz", "has_sig": false, "md5_digest": "91f53afe7cda2ef33ca7b6cf0206f499", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3959, "upload_time": "2019-09-17T05:55:34", "url": "https://files.pythonhosted.org/packages/2b/0a/8605e66bed691398a68575618179037a19238d4a75ec1f2b93ce1d4637be/django-db-connection-retrier-1.0a2.tar.gz" } ], "1.0b1": [ { "comment_text": "", "digests": { "md5": "b0fcb78d23237efd31bcfc7794c024ab", "sha256": "e0281970b9338eb30210a8a7dff004a12b80e5bba826870e9fee9f092bd7a9d9" }, "downloads": -1, "filename": "django-db-connection-retrier-1.0b1.tar.gz", "has_sig": false, "md5_digest": "b0fcb78d23237efd31bcfc7794c024ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3960, "upload_time": "2019-09-17T06:06:32", "url": "https://files.pythonhosted.org/packages/6e/76/57a89c1b6ff0b4fd24ec3172505b8fd0ce0911571c1159ee21b56ee746a9/django-db-connection-retrier-1.0b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b0fcb78d23237efd31bcfc7794c024ab", "sha256": "e0281970b9338eb30210a8a7dff004a12b80e5bba826870e9fee9f092bd7a9d9" }, "downloads": -1, "filename": "django-db-connection-retrier-1.0b1.tar.gz", "has_sig": false, "md5_digest": "b0fcb78d23237efd31bcfc7794c024ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3960, "upload_time": "2019-09-17T06:06:32", "url": "https://files.pythonhosted.org/packages/6e/76/57a89c1b6ff0b4fd24ec3172505b8fd0ce0911571c1159ee21b56ee746a9/django-db-connection-retrier-1.0b1.tar.gz" } ] }