Skip to main content

django-database-routing

Provides Primary/Replica database router for Django. See https://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-example for example implementation.

build

Configuration

  1. Add router to settings.py
DATABASE_ROUTERS = ['database_routing.PrimaryReplicaRouter']
  1. Configure 'default' and 'replica' connections in settings.DATABASES
  2. If needed you can force specific connections for some apps or models:
PRIMARY_REPLICA_ROUTING = {
  'my_app.MyModel': {
    'read': 'custom_connection',
    'write': 'custom_connection
  }
}

Forcing reading from primary

When transaction isolation level or replication lag causing bugs in your project, you can force your code to read all the data from default (or primary) database.

from database_routing import force_primary_read
@force_primary_read
def do_some_reads_and_updates():
    # All Django ORM queries are going to 'default' database here.
    # ...
    

Release files for django-database-routing 1.1.1

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

Source distribution (sdist)

Source distribution for django-database-routing 1.1.1
File Size Uploaded
django-database-routing-1.1.1.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-database-routing 1.1.1
File Interpreter ABI Platform
django_database_routing-1.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.0 kB

Release files / django-database-routing-1.1.1.tar.gz

Download URL django-database-routing-1.1.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aa858af59b5947b7db86dd6e39795b71b1b521d9ab5d38e643bb5351dd966848
BLAKE2b-256 checksum
How to use checksums
fa6d7172a36882956e56edeff15bb33e7d8de6fcd5c2b68e90bff041cc8f9bdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / django_database_routing-1.1.1-py2.py3-none-any.whl

Download URL django_database_routing-1.1.1-py2.py3-none-any.whl
Size 7.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
959bcc12754591e717967b867af73c2d02b20742502530583d0f42f9401c1032
BLAKE2b-256 checksum
How to use checksums
9fec7573b80de4e4899440302859e29e25afed1228c9de7f17e10fca9010e08c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release history Release notifications | RSS feed

1.2.0

2 release files

This release

1.1.1 This release

2 release files

1.0

2 release files

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