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?

espeed
  • 4,754
  • 2
  • 39
  • 51
dorvak
  • 9,219
  • 4
  • 34
  • 43

3 Answers3

13

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.

robsmoniker
  • 131
  • 1
  • 2
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.

sherbang
  • 15,696
  • 1
  • 22
  • 16
Matt Luongo
  • 14,371
  • 6
  • 53
  • 64
  • 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). – dorvak Dec 02 '11 at 17:53
  • 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 :) – Matt Luongo Dec 03 '11 at 17:01
  • 1
    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. – pawamoy Feb 16 '18 at 16:12
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.

sherbang
  • 15,696
  • 1
  • 22
  • 16