If Python is your language of choice, the most popular drivers are:

The easiest way to install the Python drivers for Neo4j is via PyPI (Python Package Index). You’ll find more information and installation instructions here: https://pip.pypa.io/en/latest/installing/

About connection parameters

We've used test credentials for all the following examples. Please replace them with your real connection parameters.

You'll find all the required information to connect to your database on our admin panel if you navigate to the Connection section. More on connecting to your database here

Neo4j Bolt driver for Python

The Neo4j Python driver is the one officially supported by Neo4j and connects to the database using Bolt protocol (HTTP/HTTPS not available).

Driver web page: https://github.com/neo4j/neo4j-python-driver

Bolt protocol is available in 3.0.0 or higher versions of Neo4j. You can check your Neo4j version if you navigate to the Overview page of your database.

Attention

GrapheneDB only accepts Bolt connections over TLS (1.1 and 1.2).
Bolt over TLS is only available in Python 2.7.9+ and Python 3.3+.

Installing via Python Package Index (PyPI):

$ pip install neo4j-driver

Setting up the connection:

from neo4j.v1 import GraphDatabase, basic_auth


driver = GraphDatabase.driver("bolt://hobby-geefdaeefcom.dbs.graphenedb.com:24786", auth=basic_auth("v303", "GtGq5rldxu"))

You can test the connection by creating a dummy node:

session = driver.session()


session.run("CREATE (n:Person {name:'Bob'})")
result = session.run("MATCH (n:Person) RETURN n.name AS name")
for record in result:
    print(record["name"])
session.close()

Py2Neo v3

Py2neo is a Neo4j community driver. It is a client library and toolkit for working with Neo4j from within Python applications and from the command line.

Py2Neo documentation: http://py2neo.org/v3/

Installing via Python Package Index (PyPI):

$ pip install py2neo

Attention

Since v3 supports Bolt protocol, the Bolt port has to be specified. If not using Bolt, you can specify HTTP/HTTPS instead .

Setting up the HTTP or HTTPS connection:

from py2neo import Graph, authenticate

authenticate("hobby-geefdaeefcom.dbs.graphenedb.com:24789", "v303", "GtGq5rldxu")
graph = Graph("http://hobby-geefdaeefcom.dbs.graphenedb.com:24789", bolt = False)

Setting up the Bolt/TLS connection:

from py2neo import Graph, authenticate

authenticate("hobby-geefdaeefcom.dbs.graphenedb.com:24780", "v303", "GtGq5rldxu")
graph = Graph("bolt://hobby-geefdaeefcom.dbs.graphenedb.com:24786", user="v303", password="GtGq5rldxu", bolt=True, secure = True, http_port = 24789, https_port = 24780)

Attention

Note that either HTTP or HTTPS must be enabled to allow for discovery and for some legacy features to be supported.

You can test the connection by creating a dummy node:

graph.run("CREATE (n:Person {name:'Bob'})")
result = graph.run("MATCH (n:Person) RETURN n")
for record in result:
    print(record)

Neo4j Rest Client

Please note

This driver doesn’t support the new binary Bolt protocol.

Neo4j Rest Client is a Neo4j community driver. This driver enables Python programmers already using Neo4j locally through python-embedded, to use the Neo4j REST server.

Neo4j Rest Client documentation page: http://neo4j-rest-client.readthedocs.io/en/latest/

Installing via Python Package Index (PyPI):

$ pip install neo4jrestclient

Setting up the connection:

from neo4jrestclient.client import GraphDatabase


gdb = GraphDatabase(http://hobby-geefdaeefcom.dbs.graphenedb.com:24789/db/data/, username = v303, password = GtGq5rldxu)

Test the connection by querying the database:

gdb.query("CREATE (n:Person {name:'Bob'})")
result = gdb.query("MATCH (n:Person) RETURN n LIMIT 1")
for record in result:
    print(record)

Python