跳转到主要内容

基于Django的API,用于提供URLid + 图数据库服务

项目描述

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.

安装和配置

  1. 将 "urlid_graph" 添加到您的 INSTALLED_APPS 设置中,如下所示
INSTALLED_APPS = [
    ...
    "urlid_graph",
]
  1. 更改数据库配置(此示例使用 python-decouple
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"]
  1. 配置Django缓存系统(用于存储 ElementConfig 标签)
CACHES = {
    "default": {
        "BACKEND": "django.core.cache.backends.locmem.LocMemCache",
        "TIMEOUT": 24 * 3600,
        "MAX_ENTRIES": 1024,
    }
}
  1. urlid_graph URLconf 包含在项目的 urls.py 中,如下所示:
    path('v1/', include("urlid_graph.urls")),
  1. 运行 python manage.py migrate 创建所需的模型、触发器等。

  2. 填充数据库

# 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

导入数据

python manage.py import_objects appname Model file.csv[.gz|.xz]
python manage.py import_relationship relname file.csv[.gz|.xz]

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

django_urlid_graph-0.5.11.tar.gz (33.4 kB 查看哈希值)

上传时间