Skip to main content

Simple and usable database router for django

Project description

[[TOC]]

Description

Set of simple and usable database routers for django applitaions

dbrouter.DbByAppRouter

dbrouter.DbByAppRouter allows you to specify django-applications or models, that will work with this database.

dbrouter.RestrictMigrations

dbrouter.RestrictMigrations allows you to specify a database to which you can not apply migrations. For example, with read-only access.

Example

INSTALLED_APPS = [
    ...
    'some_app',
    'other_app',
]

...
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'db.sqlite3',
    },
    # 'dbrouter.DbByAppRouter' usage example
    'external': {
        'NAME': 'some_other',
        .....
        'applications': [
            'some_app',                 #  all models on some_app
            'other_app.OnlyThisModel',  #  OnlyThisModel on other_app
        ],
    },
    # 'dbrouter.RestrictMigrations' usage example
    'some_read_only_external_database': {
        'NAME': 'some_read_only_external_database',
        .....
        'allow_migrate': False,
        # False - disable migrations
        # True - do not disable migrations
        # None - default
    },
}

...
DATABASE_ROUTERS = [
    'dbrouter.DbByAppRouter',
    'dbrouter.RestrictMigrations',
    ...
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-dbrouter, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django-dbrouter-0.1.1.zip (7.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page