简单实用的django数据库路由器
django-dbrouter的Python项目详细描述
[[toc]]
说明
django应用程序的一组简单且可用的数据库路由器
dbrouter.dbbyapprouter
dbrouter.DbByAppRouter
允许您指定django应用程序或模型,它们将与此数据库一起工作。
dbrouter.restrictmigrations
dbrouter.RestrictMigrations
允许您指定一个不能应用迁移的数据库。
例如,具有只读访问权限。
示例
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',...]