Goals This guide provides an overview of how to connecting to Neo4j from Python. While it is not comprehensive, it aims to introduce the available drivers and links to other relevant resources. Prerequisites You should be familiar with graph database… Learn More →

Goals
This guide provides an overview of how to connecting to Neo4j from Python. While it is not comprehensive, it aims to introduce the available drivers and links to other relevant resources.
Prerequisites
Intermediate

python logo master v3 TM


For anyone working with Python, the Neo4j community have contributed a range of driver options. These range from lightweight to comprehensive driver packages as well as libraries designed for use with web frameworks such as Django. Python support is well-established for Neo4j, with REST drivers having existed since 2011 and python-embedded before that.

Note
The python-embedded project is no longer maintained and supported by Neo Technology.

Both Python 2 and Python 3 are supported by most of the libraries listed here and this should help give more flexibility when putting together your Neo4j-based technology stack. While we do not provide a specific web framework recommendation, both the lightweight Flask and the more comprehensive Django frameworks are known to work well.

Many Pythonistas have invested a lot of time and love to develop these libraries, so if you use them, please provide feedback to the authors and help us improve.


Py2neo

Py2neo is a client library and comprehensive toolkit for working with Neo4j from within Python applications and from the command line. The core library has no external dependencies and has been carefully designed to be easy and intuitive to use.

py2neo.200x200

Author:

Nigel Small

Website:

http://py2neo.org/

Source:

https://github.com/nigelsmall/py2neo

Package:

https://pypi.python.org/pypi/py2neo

Documentation:

http://py2neo.org/

Example Project:

https://github.com/neo4j-examples/movies-python-py2neo-2.0

Python:

2.7 / 3.3 / 3.4

Neo4j:

1.8 / 1.9 / 2.0 / 2.1 / 2.2

Installation

pip install py2neo

Example

from py2neo import Graph, Path
graph = Graph()

tx = graph.cypher.begin()
for name in ["Alice", "Bob", "Carol"]:
    tx.append("CREATE (person:Person {name:{name}}) RETURN person", name=name)
alice, bob, carol = [result.one for result in tx.commit()]

friends = Path(alice, "KNOWS", bob, "KNOWS", carol)
graph.create(friends)

Neo4jRestClient

The main goal of neo4j-rest-client was to enable Python programmers already using Neo4j locally through python-embedded, to use the Neo4j REST server. So the syntax of neo4j-rest-client’s API is fully compatible with python-embedded. However, a new syntax is introduced in order to reach a more pythonic style and to enrich the API with the new features the Neo4j team introduces.

Author:

Javier de la Rosa

Website:

http://neo4j-rest-client.readthedocs.org/

Source:

https://github.com/versae/neo4j-rest-client

Package:

https://pypi.python.org/pypi/neo4jrestclient/

Documentation:

http://neo4j-rest-client.readthedocs.org/

Example Project:

https://github.com/neo4j-examples/movies-python-neo4jrestclient

Installation

Available through Python Package Index:

$ pip install neo4jrestclient

Or the old way:

$ easy_install neo4jrestclient

You can also install the development branch:

$ pip install git+https://github.com/versae/neo4j-rest-client.git

Bulbflow

Bulbs is an open-source Python persistence framework for graph databases and the first piece of a larger web development toolkit. It’s like an ORM for graphs.

blubflow.200x200

Author:

James Thornton

Website:

http://bulbflow.com/

Source:

https://github.com/espeed/bulbs

Package:

https://pypi.python.org/pypi/bulbs

Documentation:

http://bulbflow.com/docs/

Python:

2.6 / 2.7 / 3.0 / 3.1 / 3.2

Installation

You can use pip to install the latest version from GitHub into your project’s virtual environment:

$ mkdir example
$ cd example
$ virtualenv env
$ source env/bin/activate
(env)$ pip install https://github.com/espeed/bulbs/tarball/master

Or you can use pip to install a potentially slightly older version from PyPi:

$ mkdir example
$ cd example
$ virtualenv env
$ source env/bin/activate
(env)$ pip install bulbs

Neo4jdb-Python

Implements the Python DB API 2.0 for Neo4j.

Author:

Jacob Hansson

Website:

https://github.com/jakewins/neo4jdb-python

Source:

https://github.com/jakewins/neo4jdb-python

Package:

https://pypi.python.org/pypi/neo4jdb

Documentation:

https://github.com/jakewins/neo4jdb-python/blob/master/README.rst

Python:

2.6 / 2.7 / 3.2 / 3.3

Neo4j:

2.0 / 2.1

Installation

pip install neo4jdb

Neo4django

Neo4django is an Object Graph Mapper (OGM) for Django. Use familiar Django models and queries against Neo4j.

Author:

Matt Luongo

Website:

https://neo4django.readthedocs.org/

Source:

http://github.com/scholrly/neo4django

Package:

https://pypi.python.org/pypi/neo4django

Documentation:

https://neo4django.readthedocs.org/

Installation

Using pip, you can install from PyPi:

pip install neo4django

or straight from GitHub:

pip install -e git+https://github.com/scholrly/neo4django/#egg=neo4django

NeoModel

An Object Graph Mapper (OGM) also usable for Django for the Neo4j graph database.

neomodel.200x80

Author:

Robin Edwards

Website:

http://neomodel.readthedocs.org/

Source:

http://github.com/robinedwards/neomodel

Package:

https://pypi.python.org/pypi/neomodel

Documentation:

http://neomodel.readthedocs.org/

Python:

2.7 / 3.4 / pypy / pypy3

Neo4j:

2.0 / 2.1

Installation

Install from pypi (recommended):

$ pip install neomodel

To install from github:

$ pip install git+git://github.com/robinedwards/neomodel.git@HEAD#egg=neomodel-dev