neo4j

Neo4j Bolt driver for Python

109 个版本 Python >=3.10
安装
pip install neo4j
poetry add neo4j
pipenv install neo4j
conda install neo4j
描述

Neo4j Bolt Driver for Python


This repository contains the official Neo4j driver for Python.

Driver upgrades within a major version will never contain breaking API changes.

For version compatibility with Neo4j server, please refer to: https://neo4j.com/developer/kb/neo4j-supported-versions/

  • Python 3.14 supported.
  • Python 3.13 supported.
  • Python 3.12 supported.
  • Python 3.11 supported.
  • Python 3.10 supported.

Installation

To install the latest stable version, use:

.. code:: bash

pip install neo4j

.. TODO: 7.0 - remove this note

.. note::

``neo4j-driver`` is the old name for this package. It is now deprecated and
and will receive no further updates starting with 6.0.0. Make sure to
install ``neo4j`` as shown above.

Alternative Installation for Better Performance

You may want to have a look at the available Rust extensions for this driver for better performance. The Rust extensions are not installed by default. For more information, see neo4j-rust-ext_.

.. _neo4j-rust-ext: https://github.com/neo4j/neo4j-python-driver-rust-ext

Quick Example

.. code-block:: python

from neo4j import GraphDatabase, RoutingControl


URI = "neo4j://localhost:7687"
AUTH = ("neo4j", "password")


def add_friend(driver, name, friend_name):
    driver.execute_query(
        "MERGE (a:Person {name: $name}) "
        "MERGE (friend:Person {name: $friend_name}) "
        "MERGE (a)-[:KNOWS]->(friend)",
        name=name, friend_name=friend_name, database_="neo4j",
    )


def print_friends(driver, name):
    records, _, _ = driver.execute_query(
        "MATCH (a:Person)-[:KNOWS]->(friend) WHERE a.name = $name "
        "RETURN friend.name ORDER BY friend.name",
        name=name, database_="neo4j", routing_=RoutingControl.READ,
    )
    for record in records:
        print(record["friend.name"])


with GraphDatabase.driver(URI, auth=AUTH) as driver:
    add_friend(driver, "Arthur", "Guinevere")
    add_friend(driver, "Arthur", "Lancelot")
    add_friend(driver, "Arthur", "Merlin")
    print_friends(driver, "Arthur")

Further Information

  • The Neo4j Operations Manual_ (docs on how to run a Neo4j server)
  • The Neo4j Python Driver Manual_ (good introduction to this driver)
  • Python Driver API Documentation_ (full API documentation for this driver)
  • Neo4j Cypher Cheat Sheet_ (summary of Cypher syntax - Neo4j's graph query language)
  • Example Project_ (small web application using this driver)
  • GraphAcademy_ (interactive, free online trainings for Neo4j)
  • Driver Wiki_ (includes change logs)
  • Neo4j Migration Guide_

.. _The Neo4j Operations Manual: https://neo4j.com/docs/operations-manual/current/ .. _The Neo4j Python Driver Manual: https://neo4j.com/docs/python-manual/current/ .. _Python Driver API Documentation: https://neo4j.com/docs/api/python-driver/current/ .. _Neo4j Cypher Cheat Sheet: https://neo4j.com/docs/cypher-cheat-sheet/ .. _Example Project: https://github.com/neo4j-examples/movies-python-bolt .. _GraphAcademy: https://graphacademy.neo4j.com/categories/python/ .. _Driver Wiki: https://github.com/neo4j/neo4j-python-driver/wiki .. _Neo4j Migration Guide: https://neo4j.com/docs/migration-guide/current/

版本列表
6.2.0 2026-05-04
6.1.0 2026-01-12
6.0.3 2025-11-06
6.0.2 2025-10-02
6.0.1 2025-10-01
6.0.0 2025-09-30
6.0.0a1 2025-07-21
5.28.4 2026-05-04
5.28.3 2026-01-12
5.28.2 2025-07-30
5.28.1 2025-02-10
5.28.0 2025-02-05
5.27.0 2024-11-28
5.26.0 2024-11-01
5.25.0 2024-09-26
5.24.0 2024-08-29
5.23.1 2024-08-05
5.23.0 2024-07-29
5.22.0 2024-06-27
5.21.0 2024-06-11
5.20.0 2024-04-26
5.19.0 2024-04-02
5.18.0 2024-02-29
5.17.0 2024-01-29
5.16.0 2023-12-28
5.15.0 2023-11-28
5.14.1 2023-11-03
5.14.0 2023-10-26
5.13.0 2023-09-28
5.12.0 2023-08-31
5.11.0 2023-07-31
5.10.0 2023-06-29
5.9.0 2023-05-26
5.8.1 2023-05-17
5.8.0 2023-04-28
5.7.0 2023-03-31
5.6.0 2023-02-27
5.5.0 2023-01-27
5.4.0 2023-01-09
5.3.0 2022-11-25
5.2.1 2022-11-17
5.2.0 2022-10-31
5.1.0 2022-10-11
5.0.1 2022-09-20
5.0.0 2022-09-09
5.0.0a2 2022-08-31
5.0.0a1 2022-01-03
4.4.13 2025-07-30
4.4.12 2024-04-26
4.4.11 2023-04-28
4.4.10 2022-11-28
4.4.9 2022-10-28
4.4.8 2022-09-20
4.4.7 2022-09-09
4.4.6 2022-08-31
4.4.5 2022-07-07
4.4.4 2022-06-02
4.4.3 2022-04-25
4.4.2 2022-03-15
4.4.1 2021-12-17
4.4.0 2021-11-05
4.4.0b1 2021-10-22
4.4.0a1 2021-10-15
4.3.9 2021-12-17
4.3.8 2021-11-05
4.3.7 2021-10-22
4.3.6 2021-10-05
4.3.5 2021-09-21
4.3.4 2021-08-02
4.3.3 2021-07-13
4.3.2 2021-07-08
4.3.1 2021-06-01
4.3.0 2021-05-27
4.3.0rc1 2021-05-14
4.3.0b1 2021-05-05
4.3.0a1 2021-04-20
4.2.1 2020-12-21
4.2.0 2020-11-17
4.2.0a1 2020-10-22
4.1.3 2020-12-18
4.1.2 2020-11-17
4.1.1 2020-08-27
4.1.0 2020-07-30
4.1.0rc2 2020-07-16
4.1.0rc1 2020-07-09
4.0.3 2020-08-31
4.0.2 2020-07-16
4.0.1 2020-07-03
4.0.0 2020-06-11
4.0.0rc1 2020-06-05
4.0.0b2 2020-06-03
4.0.0b1 2020-05-19
4.0.0a4 2020-04-17
4.0.0a3 2020-04-09
4.0.0a2 2020-03-27
4.0.0a1 2020-03-18
1.7.6 2019-11-11
1.7.5 2019-10-04
1.7.4 2019-05-16
1.7.3 2019-05-08
1.7.2 2019-03-07
1.7.1 2018-11-02
1.7.0 2018-10-19
1.7.0rc2 2018-10-12
1.7.0rc1 2018-10-05
1.7.0b4 2018-09-28
1.7.0b3 2018-09-07
1.7.0b2 2018-08-24
1.7.0b1 2018-08-10