# 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](https://pypi.org/project/django-urlid-graph).
## Installation and configuration
1. Add "urlid_graph" to your `INSTALLED_APPS` setting like this:
```python
INSTALLED_APPS = [
...
"urlid_graph",
]
```
2. Change database configurations (this example uses
[python-decouple](https://github.com/henriquebastos/python-decouple)):
```python
DATABASE_URL = config("DATABASE_URL") # must be set
GRAPH_DATABASE_URL = config("GRAPH_DATABASE_URL") # must be set
graph_config = config("GRAPH_DATABASE_URL", cast=db_url)
GRAPH_DATABASE = graph_config["NAME"] # must be set
DATABASES = {
"default": config("DATABASE_URL", cast=db_url),
GRAPH_DATABASE: graph_config, # must set this way
}
DATABASE_ROUTERS = ["urlid_graph.db_router.RelationAndGraphDBRouter"]
```
3. Configure Django caching system (used to store `ElementConfig` labels):
```python
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"TIMEOUT": 24 * 3600,
"MAX_ENTRIES": 1024,
}
}
```
4. Include the `urlid_graph` URLconf in your project's `urls.py` like this:
```python
path('v1/', include("urlid_graph.urls")),
```
5. Run `python manage.py migrate` to create the needed models, triggers etc.
6. Populate the database:
```shell
# 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
```shell
python manage.py import_objects appname Model file.csv[.gz|.xz]
python manage.py import_relationship relname file.csv[.gz|.xz]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/PythonicCafe/django-urlid-graph/",
"name": "django-urlid-graph",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "graph data database api",
"author": "\u00c1lvaro Justen",
"author_email": "alvarojusten@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/54/e5/17b3134c9b7c449b8db31333298b25e88c9948554d45610a911a8d6a7f2c/django_urlid_graph-0.5.11.tar.gz",
"platform": null,
"description": "# django-urlid-graph\n\nDjango-based API to serve URLid + graph database.\nThis repository hosts the app code and also a project structure so it's easier\nto develop - only the `urlid_graph` folder is packaged before [going to\nPyPI](https://pypi.org/project/django-urlid-graph).\n\n\n## Installation and configuration\n\n1. Add \"urlid_graph\" to your `INSTALLED_APPS` setting like this:\n\n```python\nINSTALLED_APPS = [\n ...\n \"urlid_graph\",\n]\n```\n\n2. Change database configurations (this example uses\n [python-decouple](https://github.com/henriquebastos/python-decouple)):\n\n```python\nDATABASE_URL = config(\"DATABASE_URL\") # must be set\nGRAPH_DATABASE_URL = config(\"GRAPH_DATABASE_URL\") # must be set\ngraph_config = config(\"GRAPH_DATABASE_URL\", cast=db_url)\nGRAPH_DATABASE = graph_config[\"NAME\"] # must be set\nDATABASES = {\n \"default\": config(\"DATABASE_URL\", cast=db_url),\n GRAPH_DATABASE: graph_config, # must set this way\n}\nDATABASE_ROUTERS = [\"urlid_graph.db_router.RelationAndGraphDBRouter\"]\n```\n\n3. Configure Django caching system (used to store `ElementConfig` labels):\n\n```python\nCACHES = {\n \"default\": {\n \"BACKEND\": \"django.core.cache.backends.locmem.LocMemCache\",\n \"TIMEOUT\": 24 * 3600,\n \"MAX_ENTRIES\": 1024,\n }\n}\n```\n\n4. Include the `urlid_graph` URLconf in your project's `urls.py` like this:\n\n```python\n path('v1/', include(\"urlid_graph.urls\")),\n```\n\n5. Run `python manage.py migrate` to create the needed models, triggers etc.\n\n6. Populate the database:\n\n```shell\n# you may want to add entities to urlid_graph_entity model\npython manage.py import_config data/config.csv # must create this file before\npython manage.py import_config data/config.csv # must create this file before\npython manage.py import_objects appname Model file.csv.xz # must create model\npython manage.py import_relationships relname file.csv.xz\n```\n\n\n## Importing data\n\n```shell\npython manage.py import_objects appname Model file.csv[.gz|.xz]\npython manage.py import_relationship relname file.csv[.gz|.xz]\n```\n",
"bugtrack_url": null,
"license": "GNU Lesser General Public License v3 (LGPLv3)",
"summary": "Django-based API to serve URLid + graph database",
"version": "0.5.11",
"project_urls": {
"Homepage": "https://github.com/PythonicCafe/django-urlid-graph/"
},
"split_keywords": [
"graph",
"data",
"database",
"api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "54e517b3134c9b7c449b8db31333298b25e88c9948554d45610a911a8d6a7f2c",
"md5": "291067872b355361363f04097b9d63b7",
"sha256": "2a40cf67b0627772de8d215f6655b95ea5f2b64cd781f0ffe6fd2cf67b7600e1"
},
"downloads": -1,
"filename": "django_urlid_graph-0.5.11.tar.gz",
"has_sig": false,
"md5_digest": "291067872b355361363f04097b9d63b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 33423,
"upload_time": "2024-09-29T05:52:18",
"upload_time_iso_8601": "2024-09-29T05:52:18.125163Z",
"url": "https://files.pythonhosted.org/packages/54/e5/17b3134c9b7c449b8db31333298b25e88c9948554d45610a911a8d6a7f2c/django_urlid_graph-0.5.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-29 05:52:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PythonicCafe",
"github_project": "django-urlid-graph",
"github_not_found": true,
"lcname": "django-urlid-graph"
}