Article DetailsDetailsHelp DetailsThe Neo4j Python driver's session object has a read_transaction method that you can use for marking read queries explicitly. For Version 4 of the driver, the below example using the read_transaction function is correct: def get_actors(tx, movie_name): # Define Unit of work result = tx.run( "MATCH (p:Person)-[:ACTED_IN]->(m) " "WHERE toLower(m.title) CONTAINS toLower($title) " "RETURN DISTINCT p.name as actorsTx", title=movie_name) # Named parameters return [record["actorsTx"] for record in result] try: with driver.session() as session: # Run the unit of work within a Read Transaction actors = session.read_transaction(get_actors, movie_name="matrix") for actor in actors: print(f"Found actor: {actor}") except Exception as e: print(f"Exception while running read query: {e}") For Version 5 of the driver, the below example using the execute_read function is correct: def get_actors(tx, movie_name): # Define Unit of work result = tx.run( "MATCH (p:Person)-[:ACTED_IN]->(m) " "WHERE toLower(m.title) CONTAINS toLower($title) " "RETURN DISTINCT p.name as actorsTx", title=movie_name) # Named parameters return [record["actorsTx"] for record in result] try: with driver.session() as session: # Run the unit of work within a Read Transaction actors = session.execute_read(get_actors, movie_name="matrix") for actor in actors: print(f"Found actor: {actor}") except Exception as e: print(f"Exception while running read query: {e}")InformationTitleHow to mark queries as READ transactions in the official Neo4j Python driver?Article Created Date3/15/2024, 10:57 PMURL Name7182289809427-How-to-mark-queries-as-READ-transactions-in-the-official-Neo4j-Python-driverLast Modified Date3/20/2024, 7:09 PM