1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
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

34 lines
906 B
Python

"""
django-peeringdb backend loader (needed for pdb_load_data command)
"""
from django_peeringdb.client_adaptor.load import database_settings
__backend = None
def load_backend(**orm_config):
"""
Load the client adaptor module of django_peeringdb
Assumes config is valid.
"""
settings = {}
settings["SECRET_KEY"] = orm_config.get("secret_key", "")
db_config = orm_config["database"]
if db_config:
settings["DATABASES"] = {"default": database_settings(db_config)}
from peeringdb_server.client_adaptor.setup import configure
# Override defaults
configure(**settings)
# Must import implementation module after configure
from peeringdb_server.client_adaptor import backend
migrate = orm_config.get("migrate")
if migrate and not backend.Backend().is_database_migrated():
backend.Backend().migrate_database()
return backend