django-urlid-graph
Django-based API to serve URLid + graph database.
This repository hosts the app code and also a project structure so it's easier
to develop - only the urlid_graph folder is packaged before going to
PyPI.
Installation and configuration
- Add "urlid_graph" to your
INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
"urlid_graph",
]
DATABASE_URL = config("DATABASE_URL")
GRAPH_DATABASE_URL = config("GRAPH_DATABASE_URL")
graph_config = config("GRAPH_DATABASE_URL", cast=db_url)
GRAPH_DATABASE = graph_config["NAME"]
DATABASES = {
"default": config("DATABASE_URL", cast=db_url),
GRAPH_DATABASE: graph_config,
}
DATABASE_ROUTERS = ["urlid_graph.db_router.RelationAndGraphDBRouter"]
- Configure Django caching system (used to store
ElementConfig labels):
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"TIMEOUT": 24 * 3600,
"MAX_ENTRIES": 1024,
}
}
- Include the
urlid_graph URLconf in your project's urls.py like this:
path('v1/', include("urlid_graph.urls")),
# you may want to add entities to urlid_graph_entity model
python manage.py import_config data/config.csv # must create this file before
python manage.py import_config data/config.csv # must create this file before
python manage.py import_objects appname Model file.csv.xz # must create model
python manage.py import_relationships relname file.csv.xz
Importing data
python manage.py import_objects appname Model file.csv[.gz|.xz]
python manage.py import_relationship relname file.csv[.gz|.xz]