1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
peeringdb-peeringdb/peeringdb_server/db_router.py
Matt Griswold c21130eed9 Docs 202109 (#1067)
* module docstrings

* db schema graph

* dev docs first pass

* dev docs pass 2

* add generated notification to top of generated docs files

* linting

* regen docs

Co-authored-by: Stefan Pratter <stefan@20c.com>
Co-authored-by: Sunshine Buchholz <sunshine@20c.com>
2021-10-15 03:25:38 -05:00

30 lines
620 B
Python

"""
Custom django database routers.
Split read and write database connections if needed.
"""
class DatabaseRouter:
"""
A very basic database router that routes to a different
read and write db.
"""
def db_for_read(self, model, **hints):
return "read"
def db_for_write(self, model, **hints):
return "default"
def allow_relation(self, obj1, obj2, **hints):
return True
def allow_migrate(self, db, app_label, model_name=None, **hints):
return True
class TestRouter(DatabaseRouter):
def db_for_read(self, model, **hints):
return "default"