Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ambitioninc/django-dynamic-db-router
Run queries on any of your project's databases using a decorator or context manager.
https://github.com/ambitioninc/django-dynamic-db-router
Last synced: 3 months ago
JSON representation
Run queries on any of your project's databases using a decorator or context manager.
- Host: GitHub
- URL: https://github.com/ambitioninc/django-dynamic-db-router
- Owner: ambitioninc
- License: mit
- Created: 2015-02-18T22:45:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-08T01:02:26.000Z (6 months ago)
- Last Synced: 2024-07-19T20:19:14.859Z (4 months ago)
- Language: Python
- Size: 35.2 KB
- Stars: 66
- Watchers: 15
- Forks: 18
- Open Issues: 11
-
Metadata Files:
- Readme: README.rst
- Contributing: docs/contributing.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - django-dynamic-db-router - Run queries on any of your project's databases using a decorator or context manager. (Python)
README
.. image:: https://travis-ci.org/ambitioninc/django-dynamic-db-router.png
:target: https://travis-ci.org/ambitioninc/django-dynamic-db-router.. image:: https://coveralls.io/repos/ambitioninc/django-dynamic-db-router/badge.png?branch=develop
:target: https://coveralls.io/r/ambitioninc/django-dynamic-db-router?branch=develop.. image:: https://pypip.in/v/django-dynamic-db-router/badge.png
:target: https://pypi.python.org/pypi/django-dynamic-db-router/
:alt: Latest PyPI versionDjango Dynamic DB Router
========================Working with multiple databases within django is supported, but the
syntax requires peppering ``.using('my_database')`` throughout all
queries that need to be routed to different databases. This is
especially painful when trying to use libraries that were written
without multiple database support in mind. With this library, running
complex queries across different databases is as simple as:.. code-block:: python
from dynamic_db_router import in_database
with in_database('non-default-db'):
result = run_complex_query()To set up you django project to be able to use this router, simply
``pip install django-dynamic-db-router`` and add
``DATABASE_ROUTERS=['dynamic_db_router.DynamicDbRouter']`` to your
Django settings.Django Dynamic DB Router includes a number of additional features,
such as:- Using ``in_database`` as a function decorator.
- Read and write protection controls.
- Load database configurations dynamically for the lifetime of the
context manager.For more information, and complete API documentation, see the docs,
linked below.Installation
------------To install the latest release, type::
pip install django-dynamic-db-router
To install the latest code directly from source, type::
pip install git+git://github.com/ambitioninc/django-dynamic-db-router.git
Documentation
=============Full documentation is available at http://django-dynamic-db-router.readthedocs.org
License
=======
MIT License (see LICENSE)