diff --git a/code/python/example.py b/code/python/example.py index 5c224fb..8ce6bff 100644 --- a/code/python/example.py +++ b/code/python/example.py @@ -1,23 +1,21 @@ -# pip3 install neo4j-driver +# pip3 install neo4j # python3 example.py from neo4j import GraphDatabase, basic_auth -driver = GraphDatabase.driver( - "neo4j://:", - auth=basic_auth("", "")) - cypher_query = ''' MATCH (p:Product)-[:PART_OF]->(:Category)-[:PARENT*0..]-> (:Category {categoryName:$category}) RETURN p.productName as product ''' -with driver.session(database="neo4j") as session: - results = session.read_transaction( - lambda tx: tx.run(cypher_query, - category="Dairy Products").data()) - for record in results: - print(record['product']) - -driver.close() +with GraphDatabase.driver( + "neo4j://:", + auth=("", "") +) as driver: + result = driver.execute_query( + cypher_query, + category="Dairy Products", + database_="neo4j") + for record in result.records: + print(record['product'])