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.2.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 django-database-routing 1.2.0
File Size Uploaded
django-database-routing-1.2.0.tar.gz 7.8 kB Details

Built distribution (wheel)

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

Total release size: 15.4 kB

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

Download URL django-database-routing-1.2.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2f82c8edaa8df923d1a9f59fe1a103cd2162ec65dab371f7b5c2a181c315438f
BLAKE2b-256 checksum
How to use checksums
37a91b5deaa67e22cc84593397ff93f84fcbc4696645e2987bce545811e142b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

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

Download URL django_database_routing-1.2.0-py2.py3-none-any.whl
Size 7.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2df5f95d74f120cb7c59fba7387387c023ae0c5266106b76c8e31bd7a8bedd43
BLAKE2b-256 checksum
How to use checksums
54112a458138ff98ab5480aee57e1a8e7cccfe079bc2bc62689d56350b5c23c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.1

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