ORM with Graph-Databases like Neo4j in Python
Asked Answered
H

3

20

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.

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.).

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?

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?

Hodgepodge answered 2/12, 2011 at 12:56 Comment(1)
I think there might be https://mcmap.net/q/663539/-neo4j-and-django-models that is interesting here?Spiky
G
7

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

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.

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.

Geyer answered 2/12, 2011 at 14:50 Comment(3)
Bulbflow seems quite nice, i´ll have a look at it. Is it bound to Flask etc. or can you use it "standalone" ?(i think so). Neo4j Django looks good, too, but i´d like to have a plattform/framework-independent or standalone-solution (which could be bound to a framework later on).Hodgepodge
From what I understand Bulbflow can be used standalone. @versae's answer seems to agree. And because I'm always selling- despite the name, so can neo4django- it has a few code dependencies on Django but doesn't require you to use the actual framework :)Geyer
Answer is not relevant anymore: both neo4django and bulbflow are abandoned. A more recent OGM (Object-Graph-Mapper) is neomodel, and django-neomodel if you're using Django.Pyrenees
R
14

Shameless plug... there is also my own ORM which you may also want to checkout: https://github.com/robinedwards/neomodel

It's built on top of py2neo, using cypher and rest API calls under hood, i.e no dependency on gremlin.

Romberg answered 30/10, 2012 at 17:23 Comment(2)
Note: neomodel is not built on top of py2neo anymore, but on the official neo4j-driver.Pyrenees
Wow, I went in expecting the repo to be completely deprecated, but it looks like it's had a lot of work put in, kudos!Supernatural
G
7

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

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.

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.

Geyer answered 2/12, 2011 at 14:50 Comment(3)
Bulbflow seems quite nice, i´ll have a look at it. Is it bound to Flask etc. or can you use it "standalone" ?(i think so). Neo4j Django looks good, too, but i´d like to have a plattform/framework-independent or standalone-solution (which could be bound to a framework later on).Hodgepodge
From what I understand Bulbflow can be used standalone. @versae's answer seems to agree. And because I'm always selling- despite the name, so can neo4django- it has a few code dependencies on Django but doesn't require you to use the actual framework :)Geyer
Answer is not relevant anymore: both neo4django and bulbflow are abandoned. A more recent OGM (Object-Graph-Mapper) is neomodel, and django-neomodel if you're using Django.Pyrenees
T
7

Maybe you could take a look on Bulbflow, that allows to create models in Django, Flask or Pyramid. However, it works over a REST client instead of the python-binding provided by Neo4j, so perhaps it's not as fast as the native binding is.

Tuttle answered 2/12, 2011 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.