See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
- Python 3.14 support added.
- Python 3.7, 3.8, and 3.9 support has been dropped.
- Remove deprecated package alias
neo4j-driver. Usepip install neo4jinstead. - Remove
setup.py. Please use a recent enough packaging/build tool that supportspyproject.toml - Remove deprecated modules:
neo4j.confneo4j.dataneo4j.metaneo4j.packstreamneo4j.routingneo4j.time.arithmeticneo4j.time.clock_implementationneo4j.time.hydrationneo4j.time.metaclassesneo4j.workneo4j.work.queryneo4j.work.summary
- Remove deprecated exports from
neo4j:log,Config,PoolConfig,SessionConfig,WorkspaceConfig(internal - no replacement)SummaryNotificationPosition(useSummaryInputPositioninstead)
api.Versionhas been removed as it's unused now.
ServerInfo.protocol_versionnow is atuple[int, int]insteadof aapi.Version. This should be drop-in replacement is most cases:Versionwas a sup-type oftuple[int, int]ServerInfo.protocol_versionwas already documented and typed astuple[int, int]Version's additional methods were undocumented and shouldn't have been used
- Changed errors raised under certain circumstances
ConfigurationErrorif the passedauthparameters is not valid (instead ofAuthError)- This improves the differentiation between
DriverErrorfor client-side errors andNeo4jErrorfor server-side errors.
- This improves the differentiation between
access_modeconfiguration optionValueErroron invalid value (instead ofClientError)- Consistently check the value (also for non-routing drivers)
neo4j.exceptions.UnsupportedServerProductif no common bolt protocol version could be negotiated with the server (instead of internalneo4j._exceptions.BoltHandshakeError).
UnsupportedServerProductis now a subclass ofConfigurationError(instead ofExceptiondirectly).connection_acquisition_timeoutconfiguration option- Raise
ValueErroron invalid values (instead ofClientError). - Consistently restrict the value to be strictly positive
- New
ConnectionAcquisitionTimeoutError(subclass ofDriverError) instead ofClientError(subclass ofNeo4jError) the timeout is exceeded.- This improves the differentiation between
DriverErrorfor client-side errors andNeo4jErrorfor server-side errors.
- This improves the differentiation between
- The option now spans anything required to acquire a connection.
This includes potential fetching of routing tables which in itself requires acquiring a connection. Previously, the timeout would be restarted for such auxiliary connection acquisitions.
- Raise
TypeErrorinstead ofValueErrorwhen passing aQueryobject toTransaction.run.TransactionError(subclass ofDriverError) instead ofClientError(subclass ofNeo4jError) when callingsession.run()while an explicit transaction is active on that session.- This improves the differentiation between
DriverErrorfor client-side errors andNeo4jErrorfor server-side errors. - It is now the same error raised as when trying to start an explicit transaction while another explicit transaction is already active.
- This improves the differentiation between
- Slightly change
Neo4jErrorandClientError:- Properties
messageandcodeare always astr(instead ofstr | None). - Remove possibility to override/set
messageandcodeproperties. - Remove undocumented, internal methods
Neo4jError.hydrate,Neo4jError.invalidates_all_connections, andNeo4jError.is_fatal_during_discovery. - Remove deprecated method
Neo4jError.is_retriable.
UseNeo4jError.is_retryableinstead. - Change string representation of
Neo4jErrorto include GQL error information.
- Properties
- Remove deprecated
Record.__getslice__. This magic method has been removed in Python 3.0.
If you were calling it directly, please useRecord.__getitem__(slice(...))or simplyrecord[...]instead. - Bookmarks
- Remove deprecated class
neo4j.Bookmarkin favor ofneo4j.Bookmarks. - Remove deprecated method
session.last_bookmark()in favor oflast_bookmarks(). - Deprecate passing raw sting bookmarks as
initial_bookmarkstoGraphDatabase.bookmark_manager().
Use aneo4j.Bookmarksobject instead. Driver.session()no longer accepts raw string bookmarks asbookmarksargument.
Use aneo4j.Bookmarksobject instead.
- Remove deprecated class
- Remove deprecated
ServerInfo.connection_id.
There is no replacement as this is considered internal information. - Remove deprecated driver configuration option
trust.
Usetrusted_certificatesinstead.- Remove the associated constants
neo4j.TRUST_ALL_CERTIFICATESandneo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES.
- Remove the associated constants
- Remove deprecated
session.read_transactionandsession.write_transaction.
Instead, usesession.execute_readandsession.execute_writerespectively. - Make undocumented classes
ResolvedAddress,ResolvedIPv4Address, andResolvedIPv6Addressprivate. - Rework
PreviewWarning.- Remove
ExperimentalWarningand turn the few left instances of it intoPreviewWarning. - Deprecate importing
PreviewWarningfromneo4j.
Import it fromneo4j.warningsinstead.
- Remove
- Make undocumented internal constants, helper functions, and other items private:
neo4j.apiDRIVER_BOLTDRIVER_NEO4JSECURITY_TYPE_NOT_SECURESECURITY_TYPE_SECURESECURITY_TYPE_SELF_SIGNED_CERTIFICATEcheck_access_modeparse_neo4j_uriparse_routing_context
neo4j.exceptionsCLASSIFICATION_CLIENTCLASSIFICATION_DATABASECLASSIFICATION_TRANSIENTERROR_REWRITE_MAPclient_errorstransient_errors- all other indirectly exposed items from imports (e.g.
typingasneo4j.exceptions.t)
neo4j.timeDATE_ISO_PATTERNTIME_ISO_PATTERNDURATION_ISO_PATTERNNANO_SECONDSAVERAGE_SECONDS_IN_MONTHAVERAGE_SECONDS_IN_DAYFORMAT_F_REPLACEIS_LEAP_YEARDAYS_IN_YEARDAYS_IN_MONTHround_half_to_evensymmetric_divmodDateTimeTypeDateTypeTimeType- all other indirectly exposed items from imports (e.g.
reasneo4j.time.re)
neo4j.spatialhydrate_pointdehydrate_pointpoint_type
neo4j.GraphDatabase.bolt_driver.neo4j_driver
neo4j.BoltDriverandneo4j.Neo4jDriver.open.parse_target.default_host.default_port.default_target
neo4j.graph,neo4j.addressing,neo4j.api- indirectly exposed items from imports (e.g.
collections.abc.Mappingasneo4j.graph.Mapping).
- indirectly exposed items from imports (e.g.
BoltDriverandNeo4jDriver.open.parse_target.default_host.default_port.default_target
neo4j.debugColourFormatterTaskIdFilter- all other indirectly exposed items from imports (e.g.
asyncioasneo4j.debug.asyncio)
- Deprecate
ClockTimeand its accessors- For each
neo4j.time.Date,neo4j.time.DateTime,neo4j.time.Timefrom_clock_timeandto_clock_timemethods
neo4j.time.ClockTimeitself
- For each
- Raise
ConfigurationErrorinstead of ignoring the routing context (URI query parameters) when creating a direct driver ("bolt[+s[sc]]://" scheme). - Change behavior of closed drivers:
- Raise
DriverErroron using the closed driver. - Calling
driver.close()again is now a no-op.
- Raise
- No longer implicitly closing drivers and sessions in
__del__()(finalizer/destructor).
Make sure to call.close()on them explicitly or use them in awithstatement. - Make
Summary.summary_notificationsatupleinstead of alistand type it withSequenceto signify that it should be treated as immutable. - Graph type sets (
neo4j.graph.EntitySetView) can no longer by indexed by legacyid(int, e.g.,graph.nodes[0]).
Use theelement_idinstead (str, e.g.,graph.nodes["..."]). - Make all comparator magic methods return
NotImplementedinstead ofFalse(or raisingTypeErrorin some instances) if the other operand is not of a supported type. This means that when comparing a driver type with another type is doesn't support, the other type get the chance to handle the comparison.
Affected types:neo4j.Recordneo4j.graph.Node,neo4j.graph.Relationship,neo4j.graph.Pathneo4j.time.Date,neo4j.time.Time,neo4j.time.DateTimeneo4j.spatial.Point(and subclasses)
- Configuring the driver with a URL that cannot be DNS resolved will raise a (retryable)
ServiceUnavailableerror instead of aValueError. - Separate out log entries that are session-related (including transaction retries)
form sub-logger
neo4j.poolto a new sub-loggerneo4j.session. - Notifications:
- Deprecate notifications and related APIs:
ResultSummary.notificationsResultSummary.summary_notificationsneo4j.SummaryNotificationneo4j.NotificationCategoryneo4j.NotificationDisabledCategorynotifications_disabled_categoriesdriver and session configuration option in favor ofnotifications_disabled_classifications
- Stabilize GQL status objects (use this instead of notifications):
ResultSummary.gql_status_objectsneo4j.GqlStatusObject- (
neo4j.exceptions.GqlError,neo4j.exceptions.GqlErrorClassification)
- Deprecate notifications and related APIs:
- On failed liveness check (s.
liveness_check_timeoutconfiguration option), the driver will no longer remove the remote from the cached routing tables, but only close the connection under test.
This aligns the driver with the other official Neo4j drivers. - The driver incorrectly applied a timeout hint received from the server to both read and write I/O operations.
It is now only applied to read I/O operations.
In turn, a new configuration optionconnection_write_timeoutwith a default value of30 secondsis introduced. - Adjust string representation(s) of several types:
SummaryCounters:reprandstrto conform with Python's recommendations.Pointand its subclasses:reprto conform with Python's recommendations.DurationandClockTime:reprto be more consistent with other temporal driver types.GqlStatusObject:reprto conform with Python's recommendations.SummaryInputPosition:reprto be more informative.
- Since the types of
Relationships are tied to theGraphobject they belong to, fixingpicklesupport for graph types means thatRelationships with the same name will have a different type afterdeepcopying or pickling and unpickling them or their graph. For more details, see neo4j#1133 - Drop undocumented support for Bolt protocol versions 4.1.
- No breaking or major changes.
- Python 3.13 support added.
- Deprecated setting attributes on
Neo4jErrorlikemessageandcode. - Deprecated undocumented method
Neo4jError.hydrate.
It's internal and should not be used by client code.
- No breaking or major changes.
- Made
neo4j.auth_management.RotatingClientCertificateProviderand...AsyncRotatingClientCertificateProvider(in preview) abstract classes, meaning they can no longer be instantiated directly.
Please use the provided factory methods instead:neo4j.auth_management.RotatingClientCertificateProvider.rotatingand....AsyncRotatingClientCertificateProvider.rotating()respectively.
- No breaking or major changes.
SummaryNotificationPositionhas been deprecated in favor ofSummaryInputPosition.
- No breaking or major changes.
- Implemented a hierarchical logger structure to improve log source
identification and traceability.
Introduced child loggers:neo4j.io: For socket and bolt protocol related logging.neo4j.pool: For logs pertaining to connection pooling and routing.neo4j.auth_management: For logging inside the provided AuthManager implementations.
- No breaking or major changes.
- Python 3.12 support added
- Deprecated using
neo4j.Driverandneo4j.AsyncDriverafter calling.close()on them, except for calling.close()again, which has no effects.
- No breaking or major changes.
neo4j.auth_management.ExpiringAuth'sexpires_in(in preview) was replaced byexpires_at, which is a unix timestamp.
You can useExpiringAuth(some_auth).expires_in(123)instead.
- Renamed experimental
neo4j.RoutingControl.READERStoREADandWRITERStoWRITE. - Renamed experimental
driver.query_bookmark_managertoexecute_query_bookmark_manager. - Query argument to experimental
driver.execute_querynot is typedLiteralStringinstead ofstrto help mitigate accidental Cypher injections. There are rare use-cases where a computed string is necessary. Please use# type: ignore, ortyping.castto suppress the type checking in those cases.
- Deprecated importing from
neo4j.workand its submodules. Everything should be imported directly fromneo4jinstead.
- No breaking or major changes.
- Undocumented helper methods
Neo4jError.is_fatal_during_discoveryandNeo4jError.invalidates_all_connectionshave been deprecated and will be removed without replacement in version 6.0.
- Python 3.11 support added
- Removed undocumented, unused
neo4j.data.map_type - Query strings are now typed
LiteralStringinstead ofstrto help mitigate accidental Cypher injections. There are rare use-cases where a computed string is necessary. Please use# type: ignore, ortyping.castto suppress the type checking in those cases. - The experimental bookmark manager feature was changed to no longer track
bookmarks per database.
This effectively changes the signature of almost all bookmark manager related methods:neo4j.BookmarkMangerandneo4j.AsyncBookmarkMangerabstract base classes:update_bookmarkshas no longer adatabaseargument.get_bookmarkshas no longer adatabaseargument.- The
get_all_bookmarksmethod was removed. - The
forgetmethod was removed.
neo4j.GraphDatabase.bookmark_managerandneo4j.AsyncGraphDatabase.bookmark_managerfactory methods:initial_bookmarksis no longer a mapping from database name to bookmarks but plain bookmarks.bookmarks_supplierno longer receives the database name as an argument.bookmarks_consumerno longer receives the database name as an argument.
- No breaking or major changes.
- Python 3.10 support added
- Python 3.6 support has been dropped.
Result,Session, andTransactioncan no longer be imported fromneo4j.work. They should've been imported fromneo4jall along.
Remark: It's recommended to import everything needed directly fromnoe4jif available, not its submodules or subpackages.- Experimental pipelines feature has been removed.
- Async driver (i.e., support for asyncio) has been added.
ResultSummary.server.version_infohas been removed.
UseResultSummary.server.agent,ResultSummary.server.protocol_version, or call thedbms.componentsprocedure instead.- SSL configuration options have been changed:
trusthas been deprecated and will be removed in a future release.
Usetrusted_certificatesinstead. See the API documentation for more details.
neo4j.timemodule:Duration- The constructor does not accept
subsecondsanymore.
Usemilliseconds,microseconds, ornanosecondsinstead. - The property
subsecondshas been removed.
Usenanosecondsinstead. - The property
hours_minutes_secondshas been removed.
Usehours_minutes_seconds_nanosecondsinstead. - For all math operations holds: they are element-wise on
(
months,days,nanoseconds). This affects (i.e., changes) the working of//,%,/, and*.- Years are equal to 12 months.
- Weeks are equal to 7 days.
seconds,milliseconds,microseconds, andnanosecondsare implicitly converted tonanosecondsorsecondsas fit.
- Multiplication and division allow for floats but will always result in integer values (round to nearest even).
- The constructor does not accept
Time- The constructor does not accept
floats forsecondanymore.
Usenanosecondinstead. - Ticks are now nanoseconds since midnight (
int).- The property
ticks_nshas been renamed toticks.
The oldticksis no longer supported. - The property
from_ticks_nshas been renamed tofrom_ticks.
The oldfrom_ticksis no longer supported.
- The property
- The property
secondreturns anintinstead of afloat.
Usenanosecondto get the sub-second information. - The property
hour_minute_secondhas been removed.
Usehour_minute_second_nanosecondinstead.
- The constructor does not accept
DateTime- The property
hour_minute_secondhas been removed.
Usehour_minute_second_nanosecondinstead. - The property
secondreturns anintinstead of afloat.
Usenanosecondto get the sub-second information.
- The property
- Creation of a driver with
bolt[+s[sc]]://scheme and a routing context has been deprecated and will raise an error in the Future. The routing context was and will be silently ignored until then. - Bookmarks
Session.last_bookmarkwas deprecated. Its behaviour is partially incorrect and cannot be fixed without breaking its signature.
UseSession.last_bookmarksinstead.neo4j.Bookmarkwas deprecated.
Useneo4j.Bookmarksinstead.
- Deprecated closing of driver and session objects in their destructor.
This behaviour is non-deterministic as there is no guarantee that the
destructor will ever be called. A
ResourceWarningis emitted instead.
Make sure to configure Python to output those warnings when developing your application locally (it does not by default). - Result scope:
- Records of Results cannot be accessed (
peek,single,iter, ...) after their owning transaction has been closed, committed, or rolled back. Previously, this would yield undefined behavior. It now raises aResultConsumedError. - Records of Results cannot be accessed (
peek,single,iter, ...) after the Result has been consumed (Result.consume()). Previously, this would always yield no records. It now raises aResultConsumedError. - New method
Result.closed()can be used to check for this condition if necessary.
- Records of Results cannot be accessed (
- The undocumented return value of
driver.verify_connectivity()has been removed. If you need information about the remote server, usedriver.get_server_info()instead. - Transaction functions (a.k.a. managed transactions):
The first argument of transaction functions is now aManagedTransactionobject. It behaves exactly like a regularTransactionobject, except it does not offer thecommit,rollback,close, andclosedmethods.
Those methods would have caused a hard to interpreted error previously. Hence, they have been removed. - Deprecated Nodes' and Relationships'
idproperty (int) in favor ofelement_id(str).
This also affectsGraphobjects as indexinggraph.nodes[...]andgraph.relationships[...]with integers has been deprecated in favor of indexing them with strings. ServerInfo.connection_idhas been deprecated and will be removed in a future release. There is no replacement as this is considered internal information.- Output of logging helper
neo4j.debug.watchchanges- ANSI colour codes for log output are now opt-in
- Prepend log format with log-level (if colours are disabled)
- Prepend log format with thread name and id
- Deprecated
neo4j.exceptions.Neo4jError.is_retriable().
Useneo4j.exceptions.Neo4jError.is_retryable()instead. - Importing submodules from
neo4j.time(neo4j.time.xyz) has been deprecated. Everything needed should be imported fromneo4j.timedirectly. neo4j.spatial.hydrate_pointandneo4j.spatial.dehydrate_pointhave been deprecated without replacement. They are internal functions.- Importing
neo4j.packstreamhas been deprecated. It's internal and should not be used by client code. - Importing
neo4j.routinghas been deprecated. It's internal and should not be used by client code. - Importing
neo4j.confighas been deprecated. It's internal and should not be used by client code. neoj4.Config,neoj4.PoolConfig,neoj4.SessionConfig, andneoj4.WorkspaceConfighave been deprecated without replacement. They are internal classes.- Importing
neo4j.metahas been deprecated. It's internal and should not be used by client code.ExperimantalWarningshould be imported directly fromneo4j.neo4j.meta.versionis exposed throughneo4j.__vesrion__ - Importing
neo4j.datahas been deprecated. It's internal and should not be used by client code.Recordshould be imported directly fromneo4jinstead.neo4j.data.DataHydratorandneo4j.data.DataDeydratorhave been removed without replacement. - Removed undocumented config options that had no effect:
protocol_versionandinit_size. - Introduced
neo4j.exceptions.SessionErrorthat is raised when trying to execute work on a closed or otherwise terminated session. - Removed deprecated config options
update_routing_table_timeoutandsession_connection_timeout.
Server-side keep-alives communicated through configuration hints together with the config optionconnection_acquisition_timeoutare sufficient to avoid the driver getting stuck. - Deprecate
Session.read_transactionandSession.write_transactionin favor ofSession.execute_readandSession.execute_writerespectively.
- Python 3.5 support has been dropped.
- Python 3.9 support added
- No breaking or major changes.
- Routing context is now forwarded to the server for when required by server-side routing
- The package version has jumped from
1.7directly to4.0, in order to bring the version in line with Neo4j itself. - The package can now no longer be installed as
neo4j-driver; usepip install neo4jinstead. - The
neo4j.v1subpackage is now no longer available; all imports should be taken from theneo4jpackage instead. - Changed
session(access_mode)from a positional to a keyword argument - The
bolt+routingscheme is now namedneo4j - Connections are now unencrypted by default; to reproduce former behaviour, add
encrypted=Trueto Driver configuration - Removed
transaction.successflag usage pattern.
- Python 3.8 supported.
- Python 3.7 supported.
- Python 3.6 supported.
- Python 3.5 supported.
- Python 3.4 support has been dropped.
- Python 3.3 support has been dropped.
- Python 3.2 support has been dropped.
- Python 3.1 support has been dropped.
- Python 3.0 support has been dropped.
- Python 2.7 support has been dropped.