{ "info": { "author": "Jeff Balogh", "author_email": "jbalogh@mozilla.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Environment :: Web Environment :: Mozilla", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "``multidb`` provides two Django database routers useful in primary-replica database\ndeployments.\n\n\nReplicaRouter\n-----------------\n\nWith ``multidb.ReplicaRouter`` all read queries will go to a replica\ndatabase; all inserts, updates, and deletes will go to the ``default``\ndatabase.\n\nFirst, define ``REPLICA_DATABASES`` in your settings. It should be a list of\ndatabase aliases that can be found in ``DATABASES``::\n\n DATABASES = {\n 'default': {...},\n 'shadow-1': {...},\n 'shadow-2': {...},\n }\n REPLICA_DATABASES = ['shadow-1', 'shadow-2']\n\nThen put ``multidb.ReplicaRouter`` into DATABASE_ROUTERS::\n\n DATABASE_ROUTERS = ('multidb.ReplicaRouter',)\n\nThe replica databases will be chosen in round-robin fashion.\n\nIf you want to get a connection to a replica in your app, use\n``multidb.get_replica``::\n\n from django.db import connections\n import multidb\n\n connection = connections[multidb.get_replica()]\n\n\nPinningReplicaRouter\n------------------------\n\nIn some applications, the lag between the primary database receiving a write and its\nreplication to the replicas is enough to cause inconsistency for the end user.\nFor example, imagine a scenario with 1 second of replication lag. If a user\nmakes a forum post (to the primary) and then is redirected to a fully-rendered\nview of it (from a replica) 500ms later, the view will fail. If this is a problem\nin your application, consider using ``multidb.PinningReplicaRouter``. This\nrouter works in combination with ``multidb.middleware.PinningRouterMiddleware``\nto assure that, after writing to the ``default`` database, future reads from\nthe same user agent are directed to the ``default`` database for a configurable\nlength of time.\n\nCaveats\n=======\n\n``PinningRouterMiddleware`` identifies database writes primarily by request\ntype, assuming that requests with HTTP methods that are not ``GET``, ``TRACE``,\n``HEAD``, or ``OPTIONS`` are writes. You can indicate that any view writes to\nthe database by using the ``multidb.db_write`` decorator. This will cause the\nsame result as if the request were, e.g., a ``POST``.\n\nYou can also manually set ``response._db_write = True`` to indicate that a\nwrite occurred. This will not result in using the ``default`` database in this\nrequest, but only in the next request.\n\nConfiguration\n=============\n\nTo use ``PinningReplicaRouter``, put it into ``DATABASE_ROUTERS`` in your\nsettings::\n\n DATABASE_ROUTERS = ('multidb.PinningReplicaRouter',)\n\nThen, install the middleware. It must be listed before any other middleware\nwhich performs database writes::\n\n MIDDLEWARE_CLASSES = (\n 'multidb.middleware.PinningRouterMiddleware',\n ...more middleware here...\n )\n\n``PinningRouterMiddleware`` attaches a cookie to any user agent who has just\nwritten. The cookie should be set to expire at a time longer than your\nreplication lag. By default, its value is a conservative 15 seconds, but it can\nbe adjusted like so::\n\n MULTIDB_PINNING_SECONDS = 5\n\nIf you need to change the name of the cookie, use the ``MULTIDB_PINNING_COOKIE``\nsetting::\n\n MULTIDB_PINNING_COOKIE = 'multidb_pin_writes'\n\n\n``use_primary_db``\n==============\n\n``multidb.pinning.use_primary_db`` is both a context manager and a decorator for\nwrapping code to use the primary database. You can use it as a context manager::\n\n from multidb.pinning import use_primary_db\n\n with use_primary_db:\n touch_the_database()\n touch_another_database()\n\nor as a decorator::\n\n from multidb.pinning import use_primary_db\n\n @use_primary_db\n def func(*args, **kw):\n \"\"\"Touches the primary database.\"\"\"\n\n\nRunning the Tests\n-----------------\n\nTo run the tests, you'll need to install the development requirements::\n\n pip install -r requirements.txt\n ./run.sh test\n\nAlternatively, you can run the tests with several versions of Django\nand Python using tox:\n\n $ pip install tox\n\n $ tox\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jbalogh/django-multidb-router", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-multidb-router", "package_url": "https://pypi.org/project/django-multidb-router/", "platform": "", "project_url": "https://pypi.org/project/django-multidb-router/", "project_urls": { "Homepage": "https://github.com/jbalogh/django-multidb-router" }, "release_url": "https://pypi.org/project/django-multidb-router/0.9/", "requires_dist": [ "Django (>=1.11)" ], "requires_python": "", "summary": "Round-robin multidb router for Django.", "version": "0.9" }, "last_serial": 4855491, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "305a907896352347c2c00d625a7852ea", "sha256": "1c74e2fa5a731eb751e53c6e2ea53adc0cf92e72ded2332b95c45fda6d67b6ae" }, "downloads": -1, "filename": "django-multidb-router-0.2.tar.gz", "has_sig": false, "md5_digest": "305a907896352347c2c00d625a7852ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3265, "upload_time": "2010-02-09T17:04:22", "url": "https://files.pythonhosted.org/packages/ee/a7/c8132d55c7f7db39472cc0c40c2ba271f0ac175ca5a5dc49ff5ab7662420/django-multidb-router-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "0071dcfbb31fc705430a529bdfcb99fa", "sha256": "5a22235a683a662722ec80c7e666ccb1622b0628476e89eede098eb3724dd5dd" }, "downloads": -1, "filename": "django-multidb-router-0.3.tar.gz", "has_sig": false, "md5_digest": "0071dcfbb31fc705430a529bdfcb99fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3265, "upload_time": "2010-02-09T19:11:20", "url": "https://files.pythonhosted.org/packages/f8/26/f73b416371689e6fcde768de9131f26914fbedce4cd4e319acde5c44832d/django-multidb-router-0.3.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "d4d6b341d0c18c1fa3136248a3a5a9d3", "sha256": "6ed0b597edcc24042bd60d7903f5e83f9211aade815acc4c4aff6eddf19845a0" }, "downloads": -1, "filename": "django-multidb-router-0.5.tar.gz", "has_sig": false, "md5_digest": "d4d6b341d0c18c1fa3136248a3a5a9d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7211, "upload_time": "2011-11-01T18:42:26", "url": "https://files.pythonhosted.org/packages/90/17/1472f061efd08b90e6cbcee3f5b2507a912bcacf0b8733d3673c52d2d948/django-multidb-router-0.5.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "d0b0bc6f45e29dd9ef2124e76084079b", "sha256": "00b34b24d4f32077bc53ebb940e9a50edbf086917d4b2eb6a399a05890463650" }, "downloads": -1, "filename": "django-multidb-router-0.5.1.tar.gz", "has_sig": false, "md5_digest": "d0b0bc6f45e29dd9ef2124e76084079b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7078, "upload_time": "2013-10-31T17:01:53", "url": "https://files.pythonhosted.org/packages/e3/7f/534c6d6239268e0b86f884975ce1f3de835418244483faab52c6e6a2dcaa/django-multidb-router-0.5.1.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "0146cd490ecf96a51f3c9ed63bea59a1", "sha256": "4c488dcb84cffd88bcd2b1651962b767f9bb245206407c8ea678043cd39d3ca8" }, "downloads": -1, "filename": "django-multidb-router-0.6.tar.gz", "has_sig": false, "md5_digest": "0146cd490ecf96a51f3c9ed63bea59a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7119, "upload_time": "2015-01-07T00:00:19", "url": "https://files.pythonhosted.org/packages/e9/76/50b8c9793a22c978410b676be88218602b4cdc6c94615bdf7342c36689e5/django-multidb-router-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "c3d8a35c7ac8b435be0db90dfd763378", "sha256": "8e802c09ed69a1f4ce5716524a1dc1668a8a2e25d9112369dc92c2b963e70332" }, "downloads": -1, "filename": "django_multidb_router-0.7-py2-none-any.whl", "has_sig": false, "md5_digest": "c3d8a35c7ac8b435be0db90dfd763378", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 10535, "upload_time": "2017-11-09T11:18:13", "url": "https://files.pythonhosted.org/packages/98/bb/519725033bd6093cf025475c22e9e96bd978ea42b329e9232db7e16f66d0/django_multidb_router-0.7-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d9693f8cb0d6ca79b062d1f2f7ce1cfe", "sha256": "682d2be38ca1e2a12bc33528b3d4ccddf9775c926a5667b53f840df620094a86" }, "downloads": -1, "filename": "django-multidb-router-0.7.tar.gz", "has_sig": false, "md5_digest": "d9693f8cb0d6ca79b062d1f2f7ce1cfe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7504, "upload_time": "2017-11-09T11:18:14", "url": "https://files.pythonhosted.org/packages/02/33/bc7324826f70c9bd9349314774ae8c1e584319a01daddd0cb267d6fbe22a/django-multidb-router-0.7.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "8385bb0635173776c11510cbf037a15e", "sha256": "a5ed680454811b9e4fb6937e51c959f537147e4bd474597f7ab172352016d963" }, "downloads": -1, "filename": "django_multidb_router-0.8-py2-none-any.whl", "has_sig": false, "md5_digest": "8385bb0635173776c11510cbf037a15e", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8001, "upload_time": "2018-09-03T12:21:06", "url": "https://files.pythonhosted.org/packages/4c/3a/7eb553220b23002fc85cee4f4e7b762c500e3e8acc4386025cd735036ac0/django_multidb_router-0.8-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9152d1c5c3c1275bc8fb3060bde15a97", "sha256": "3b1f460a8eea5a696bcad681e5c48f8331c934f734bdab24a72dea54ace6c4dd" }, "downloads": -1, "filename": "django-multidb-router-0.8.tar.gz", "has_sig": false, "md5_digest": "9152d1c5c3c1275bc8fb3060bde15a97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7615, "upload_time": "2018-09-03T12:21:08", "url": "https://files.pythonhosted.org/packages/70/a5/db9bd129a143bef04137a502bde0b24c0669078d32b56f293277323b265e/django-multidb-router-0.8.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "5fe5bc9f3af0e7ced2d38fae94631bee", "sha256": "38a006455fa1141a332029791863461c0b1f287b8c479b411b4d9f728e86e97a" }, "downloads": -1, "filename": "django_multidb_router-0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "5fe5bc9f3af0e7ced2d38fae94631bee", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9778, "upload_time": "2019-02-22T18:44:17", "url": "https://files.pythonhosted.org/packages/4e/cf/5e6a92d88e54ac532dfee9b69d260678ca8af5bbac5164e3bafdb58ba4d8/django_multidb_router-0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ea3651565d9f30cd96b318a92b414b01", "sha256": "d8096eff3a42743a795bb943260758d169bc78de61e12eeb0893d6dbfbae72d0" }, "downloads": -1, "filename": "django-multidb-router-0.9.tar.gz", "has_sig": false, "md5_digest": "ea3651565d9f30cd96b318a92b414b01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8379, "upload_time": "2019-02-22T18:44:18", "url": "https://files.pythonhosted.org/packages/68/19/5f48a52eb03b6ee630ab318386c94597bb09956dc930520ff4ca0bf7f764/django-multidb-router-0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5fe5bc9f3af0e7ced2d38fae94631bee", "sha256": "38a006455fa1141a332029791863461c0b1f287b8c479b411b4d9f728e86e97a" }, "downloads": -1, "filename": "django_multidb_router-0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "5fe5bc9f3af0e7ced2d38fae94631bee", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9778, "upload_time": "2019-02-22T18:44:17", "url": "https://files.pythonhosted.org/packages/4e/cf/5e6a92d88e54ac532dfee9b69d260678ca8af5bbac5164e3bafdb58ba4d8/django_multidb_router-0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ea3651565d9f30cd96b318a92b414b01", "sha256": "d8096eff3a42743a795bb943260758d169bc78de61e12eeb0893d6dbfbae72d0" }, "downloads": -1, "filename": "django-multidb-router-0.9.tar.gz", "has_sig": false, "md5_digest": "ea3651565d9f30cd96b318a92b414b01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8379, "upload_time": "2019-02-22T18:44:18", "url": "https://files.pythonhosted.org/packages/68/19/5f48a52eb03b6ee630ab318386c94597bb09956dc930520ff4ca0bf7f764/django-multidb-router-0.9.tar.gz" } ] }