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.
dbrouter.parse_database_url
dbrouter.parse_database_url
allows you to specify a database connection as one string
Example
from dbrouter import parse_database_url
# ...
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
},
'some_db_added_by_url': parse_database_url(
# DB in remoge PostgreSQL-server on some schema
'psql://user:pass@remote.db.host/options=-c search_path=some_schema',
applications=['some_new_app'],
allow_migrate=False)
}
...
DATABASE_ROUTERS = [
'dbrouter.DbByAppRouter',
'dbrouter.RestrictMigrations',
...
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-dbrouter-0.1.4.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7545c6e622124350c0f95a2c745822701de86560c2a49fd0573bc3d192eb023c |
|
MD5 | f7261f8f329390da159495e1c657e9d7 |
|
BLAKE2b-256 | b213d5f66f041c337702c1b2e4da885bb9d30282d944d11e3ed7180e7976e766 |
Close
Hashes for django_dbrouter-0.1.4.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb3a42ee310ce9e5b88712b3031531469a2b2b8e03a5e97537f88b757890119d |
|
MD5 | 246eb550845e1b21e5ddc769dda3aef0 |
|
BLAKE2b-256 | 1ed81bd17400580c589a983e3a0e8c33610822131ed79f623c72b0bfbfbbeb55 |