The py2neo project provides bindings between Python and Neo4j via its RESTful web service interface. It attempts to be both Pythonic and consistent with the core Neo4j API.
Pull request Compare This branch is 785 commits behind nigelsmall:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
art
bin
doc
scripts
src/py2neo
test/py2neo
tutorials
www
.gitignore
LICENSE
MANIFEST.in
NOTICE
README.creole
VERSION
setup.py

README.creole

Py2neo

The py2neo project provides bindings between Python and Neo4j via its RESTful web service interface. It attempts to be both Pythonic and consistent with the core Neo4j API.

In addition, the project provides support for the Graph Export Object File Format (Geoff). For further information on Geoff, visit http://geoff.nigelsmall.net/.

Requirements

Py2neo has been built against the following software:

Earlier versions of these may work but are not guaranteed to do so.

Installation

The easiest way to install py2neo is from the Python Package Index (PyPI), using pip:

sudo pip install py2neo

You will also need to ensure that tornado is installed and up to date. This can be achieved with:

sudo pip install --upgrade tornado

Alternatively, you may prefer to use the latest code directly from GitHub:

git clone git@github.com:nigelsmall/py2neo.git

Getting Started

The following short programme illustrates a simple usage of the py2neo library:

<<code lang="python">>

#!/usr/bin/env python

"""
Simple example showing node and relationship creation plus
execution of Cypher queries
"""

from __future__ import print_function

# Import Neo4j modules
from py2neo import neo4j, cypher

# Attach to the graph db instance
graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")

# Create two nodes
node_a, node_b = graph_db.create(
    {"name": "Alice"},
    {"name": "Bob"}
)

# Join the nodes with a relationship
rel_ab = node_a.create_relationship_to(node_b, "KNOWS")

# Build a Cypher query
query = "START a=node({A}) MATCH a-[:KNOWS]->b RETURN a,b"

# Define a row handler...
def print_row(row):
    a, b = row
    print(a["name"] + " knows " + b["name"])

# ...and execute the query
cypher.execute(graph_db, query, {"A": node_a.id}, row_handler=print_row)

<</code>>

For more examples, browse the tutorials or for full details of the functionality available, check out the API documentation.