带有图形数据库(如 Python 中的 Neo4j)的 ORM [英] ORM with Graph-Databases like Neo4j in Python

查看:32
本文介绍了带有图形数据库(如 Python 中的 Neo4j)的 ORM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有解决方案(或需要)带有图形数据库(例如 Neo4j)的 ORM.我正在跟踪实体(包括这些实体的附加属性)的关系(A 与 B 相关,B 通过 C 等与 A 相关,从而构建一个大图)并且需要将它们存储在数据库中,我认为图数据库非常适合这项任务.

i wonder wether there is a solution (or a need for) an ORM with Graph-Database (f.e. Neo4j). I'm tracking relationships (A is related to B which is related to A via C etc., thus constructing a large graph) of entities (including additional attributes for those entities) and need to store them in a DB, and i think a graph database would fit this task perfectly.

现在,对于类似 sql 的数据库,我使用 sqlalchemyś ORM 来存储我的对象,特别是因为我可以从数据库中检索对象并以 Python 风格使用它们(使用它们的方法等).

Now, with sql-like DBs, i use sqlalchemyś ORM to store my objects, especially because of the fact that i can retrieve objects from the db and work with them in a pythonic style (use their methods etc.).

是否有适用于 Neo4j 或其他 Graph-DB 的对象映射解决方案,以便我可以在 Graph-DB 中存储和检索 Python 对象并轻松使用它们?

Is there any object-mapping solution for Neo4j or other Graph-DB, so that i can store and retrieve python objects into and from the Graph-DB and work with them easily?

或者你会在 python sqlite 文档 (http://docs.python.org/library/sqlite3.html#letting-your-object-adapt-itself) 中编写一些函数或适配器来检索和存储对象?

Or would you write some functions or adapters like in the python sqlite documentation (http://docs.python.org/library/sqlite3.html#letting-your-object-adapt-itself) to retrieve and store objects?

推荐答案

基于数据库的 REST 接口,目前有几个 Python 选择.

There are a couple choices in Python out there right now, based on databases' REST interfaces.

正如我在@Peter 提供的链接中提到的,我们正在开发 neo4django,它更新了旧的 Neo4j/Django 集成.如果您需要复杂的查询并且想要一个 ORM 来管理节点索引,或者如果您已经在使用 Django,这是一个不错的选择.它的工作原理与原生 Django ORM 非常相似.在 PyPiGitHub.

As I mentioned in the link @Peter provided, we're working on neo4django, which updates the old Neo4j/Django integration. It's a good choice if you need complex queries and want an ORM that will manage node indexing as well- or if you're already using Django. It works very similarly to the native Django ORM. Find it on PyPi or GitHub.

还有一个更通用的解决方案,称为 Bulbflow,它应该适用于蓝图支持的任何图形数据库.我没有使用过它,但从我所见,它专注于域建模——例如,Bulbflow 已经有工作关系模型,我们仍在研究它——但不太支持复杂的查询(正如我们所做的那样)与 Django 查询集 + 索引使用).它还可以让您更接近图表.

There's also a more general solution called Bulbflow that is supposed to work with any graph database supported by Blueprints. I haven't used it, but from what I've seen it focuses on domain modeling - Bulbflow already has working relationship models, for example, which we're still working on- but doesn't much support complex querying (as we do with Django querysets + index use). It also lets you work a bit closer to the graph.

这篇关于带有图形数据库(如 Python 中的 Neo4j)的 ORM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆