Breaking Changes

This describes the breaking changes between Python Driver 1.7 and Python Driver 4.0

Version Scheme Changes

The version number has jumped from Python Driver 1.7 to Python Driver 4.0 to align with the Neo4j Database version scheme.

Python Versions

Python 2.7 is no longer supported.

Namespace Changes

import neo4j.v1

Has changed to

import neo4j

Secure Connection

Neo4j 4.0 is by default configured to use a unsecured connection.

The driver configuration argument encrypted is by default set to False.

Note: To be able to connect to Neo4j 3.5 set encrypted=True to have it configured as the default for that setup.

from neo4j import GraphDatabase

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

Bookmark Changes

Introduced neo4j.Bookmark

Exceptions Changes

The exceptions in neo4j.exceptions has been updated and there are internal exceptions starting with the naming Bolt that should be propagated into the exceptions API.

See Errors for more about errors.

URI Scheme Changes

bolt+routing has been renamed to neo4j.

Class Renaming Changes

  • BoltStatementResult is now Result

  • StatementResultSummary is now ResultSummary

  • Statement is now Query

Argument Renaming Changes

  • statement is now query

  • cypher is now query

  • Session.run(cypher, ... is now Session.run(query, ...

  • Transaction.run(statement, ... is now Transaction.run(query, ...

  • StatementResultSummary.statement is now ResultSummary.query

  • StatementResultSummary.statement_type is now ResultSummary.query_type

  • StatementResultSummary.protocol_version is now ResultSummary.server.protocol_version

API Changes

  • Result.summary() has been replaced with Result.consume(), this behaviour is to consume all remaining records in the buffer and returns the ResultSummary.

  • Result.data(*items) has been changed to Result.data(*keys) for alignment with Record.data(*keys).

  • Result.value(item=0, default=None) has been changed to Result.value(key=0, default=None) for alignment with Record.value(key=0, default=None).

  • Result.values(*items) has been changed to Result.values(*keys) for alignment with Record.values(*keys).

  • Transaction.sync() has been removed. Use Result.consume() if the behaviour is to exhaust the result object.

  • Transaction.success has been removed.

  • Transaction.close() behaviour changed. Will now only perform rollback if no commit have been performed.

  • Session.sync() has been removed. Use Result.consume() if the behaviour is to exhaust the result object.

  • Session.detach() has been removed. Use Result.consume() if the behaviour is to exhaust the result object.

  • Session.next_bookmarks() has been removed.

  • Session.has_transaction() has been removed.

  • Session.closed() has been removed.

  • Session.write_transaction and Session.read_transaction will start the retry timer after the first failed attempt.

Dependency Changes

  • The dependency neobolt has been removed.

  • The dependency neotime has been removed.

  • The pytz is now a dependency.

Configuration Name Changes

  • max_retry_time is now max_transaction_retry_time