Breaking changes between Neo4j drivers v4.4 and v5.x.

The following are all the breaking changes between Neo4j drivers v4.4 and v5.x.

Python driver export APIs to Pandas dataframes

Adding functionality to the Python driver to export Neo4j result sets to Pandas dataframes:

import neo4j
import pandas  #required


@staticmethod
    def _find_and_return_person(tx, person_name):
        query = (
            "MATCH (p:Person) "
            "WHERE p.name = $person_name "
            "RETURN p.name AS name"
        )
        result = tx.run(query, person_name=person_name)
        df = result.to_df()
        print(df)

     name
0   Alice
1   Alice
2   Alice
3   Alice
4   Alice
5   Alice

Python driver support for the asyncio functions

Adding async support, including cancellation.

async def get_search(q: Optional[str] = None):
    async def work(tx, q_):
        result = await tx.run(
            "MATCH (movie:Movie) "
            "WHERE toLower(movie.title) CONTAINS toLower($title) "
            "RETURN movie", {"title": q_}
        )
        return [record async for record in result]

    if q is None:
        return []
    async with get_db() as db:
        results = await db.execute_read(work, q)
        return [serialize_movie(record["movie"]) for record in results]

For more information, see Async API Documentation.

Retryable flag on Error objects

A new interface/property has been added to all errors/exceptions that the driver raises. This exposes whether the driver would retry on that error type when using managed transaction functions.

# Capture any errors along with the query and data for traceability, plus whether it is retryable
   except ServiceUnavailable as exception:
   logging.error("{query} raised an error: \n {exception} \n retryable? {retryable}".format(
       query=query, exception=exception, retryable=exception.is_retryable()))

   raise