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