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

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

问题描述

我想知道是否有解决方案(或需要)带有Graph-Database(例如Neo4j)的ORM.我正在跟踪实体(包括这些实体的其他属性)的关系(A与B相关,B通过C与A相关,从而构造了一个大图),并且需要将它们存储在DB中,我认为图形数据库将完全适合此任务.

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的DB,我使用sqlalchemyśORM来存储我的对象,尤其是因为我可以从db中检索对象并以pythonic风格使用它们(使用它们的方法等).

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非常相似.在 PyPi

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 ,该解决方案可以与Blueprints支持的任何图形数据库一起使用.我没有使用过,但是从我看到的内容来看,它专注于域建模-例如,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天全站免登陆