Skip to main content

Neo4j Bolt driver for Python

Project description

This repository contains the official Neo4j driver for Python. Each driver release (from 5.0 upwards) is built specifically to work with a corresponding Neo4j release, i.e. that with the same major.minor version number. Only the latest major.minor release of each major driver series receives patches and support. These drivers will also be compatible with the previous Neo4j LTS release as well as the very next release, although only the common set of features between the chosen driver and server versions will be available.

See Version Compatibility for a compatibility matrix.

  • Python 3.10 supported.

  • Python 3.9 supported.

  • Python 3.8 supported.

  • Python 3.7 supported.

Installation

To install the latest stable version, use:

pip install neo4j

Quick Example

from neo4j import GraphDatabase

driver = GraphDatabase.driver("neo4j://localhost:7687",
                              auth=("neo4j", "password"))

def add_friend(tx, name, friend_name):
    tx.run("MERGE (a:Person {name: $name}) "
           "MERGE (a)-[:KNOWS]->(friend:Person {name: $friend_name})",
           name=name, friend_name=friend_name)

def print_friends(tx, name):
    query = ("MATCH (a:Person)-[:KNOWS]->(friend) WHERE a.name = $name "
             "RETURN friend.name ORDER BY friend.name")
    for record in tx.run(query, name=name):
        print(record["friend.name"])

with driver.session(database="neo4j") as session:
    session.execute_write(add_friend, "Arthur", "Guinevere")
    session.execute_write(add_friend, "Arthur", "Lancelot")
    session.execute_write(add_friend, "Arthur", "Merlin")
    session.execute_read(print_friends, "Arthur")

driver.close()

Connection Settings Breaking Change (4.x)

  • The driver’s default configuration for encrypted is now false (meaning that driver will only attempt plain text connections by default).

  • Connections to encrypted services (such as Neo4j Aura) should now explicitly be set to encrypted.

  • When encryption is explicitly enabled, the default trust mode is to trust the CAs that are trusted by operating system and use hostname verification.

  • This means that encrypted connections to servers holding self-signed certificates will now fail on certificate verification by default.

  • Using the new neo4j+ssc scheme will allow to connect to servers holding self-signed certificates and not use hostname verification.

  • The neo4j:// scheme replaces bolt+routing:// and can be used for both clustered and single-instance configurations with Neo4j 4.0.

See, https://neo4j.com/docs/migration-guide/4.0/upgrade-driver/#upgrade-driver-breakingchanges

See, https://neo4j.com/docs/driver-manual/current/client-applications/#driver-connection-uris for changes in default security settings between 3.x and 4.x

Connecting with Python Driver 4.x to Neo4j 3.5 (EOL)

Using the Python Driver 4.x and connecting to Neo4j 3.5 with default connection settings for Neo4j 3.5.

# the preferred form

driver = GraphDatabase.driver("neo4j+ssc://localhost:7687", auth=("neo4j", "password"))

# is equivalent to

driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("neo4j", "password"), encrypted=True, trust=False)

Connecting with Python Driver 1.7 (EOL) to Neo4j 4.x

Using the Python Driver 1.7 and connecting to Neo4j 4.x with default connection settings for Neo4j 4.x.

driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("neo4j", "password"), encrypted=False)

Version Compatibility

Server \ Driver

1.7

4.0

4.1

4.2

4.3

4.4

5.0

5.1

Neo4j 3.5 (EOL)

Yes

Yes

?

?

?

?

?

?

Neo4j 4.0 (EOL)

Yes

Yes

Yes

Yes

Yes

Yes

?

?

Neo4j 4.1 (EOL)

?

Yes

Yes

Yes

Yes

Yes

?

?

Neo4j 4.2 (EOL)

?

?

Yes

Yes

Yes

Yes

?

?

Neo4j 4.3

?

?

?

Yes

Yes

Yes

?

?

Neo4j 4.4 (LTS)

?

?

?

?

Yes

Yes

Yes

Yes

Neo4j 5.0 (EOL)

?

?

?

?

?

Yes

Yes

Yes

Neo4j 5.1

?

?

?

?

?

?

Yes

Yes

Table as of Neo4j 5.1 and Python Driver 5.1 are the latest available versions.

  • emphasized: currently supported driver versions

  • Yes: supported combination, although only the common set of features between the chosen driver and server versions will be available.

  • ?: might work, untested, no support.

  • (blank): not working.

Other Information

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neo4j-driver-5.1.0.tar.gz (173.7 kB view details)

Uploaded Source

File details

Details for the file neo4j-driver-5.1.0.tar.gz.

File metadata

  • Download URL: neo4j-driver-5.1.0.tar.gz
  • Upload date:
  • Size: 173.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.0

File hashes

Hashes for neo4j-driver-5.1.0.tar.gz
Algorithm Hash digest
SHA256 701788a9390bd6e63131d333146ffc2dae24214f639b0fb9e764ff7aeb06f13b
MD5 d3521e170d96587487a860e9e4e7cdfd
BLAKE2b-256 631d5a7939d5e81aaebcfddf518b100443f6bdde982c89bb4fb3bfeb84693ef5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page