Round-robin multidb router for Django 1.2.
Project description
With multidb.MasterSlaveRouter all read queries will go to a slave database; all inserts, updates, and deletes will do to the default database.
First, define SLAVE_DATABASES in your settings. It should be a list of database aliases that can be found in DATABASES:
DATABASES = { 'default': {...}, 'shadow-1': {...}, 'shadow-2': {...}, } SLAVE_DATABASES = ['shadow-1', 'shadow-2']
Then put multidb.MasterSlaveRouter into DATABASE_ROUTERS:
DATABASE_ROUTERS = ('multidb.MasterSlaveRouter',)
The slave databases will be chosen in round-robin fashion.
If you want to get a connection to a slave in your app, use multidb.get_slave:
from django.db import connections import multidb connection = connections[multidb.get_slave()]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-multidb-router-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c74e2fa5a731eb751e53c6e2ea53adc0cf92e72ded2332b95c45fda6d67b6ae |
|
MD5 | 305a907896352347c2c00d625a7852ea |
|
BLAKE2b-256 | eea7c8132d55c7f7db39472cc0c40c2ba271f0ac175ca5a5dc49ff5ab7662420 |