Skip to content

Commit b4dc295

Browse files
robsdedudefbiville
authored andcommitted
Update python example to use execute_query
Using the new simpler API introduced in drivers 5.5 and stabilized in 5.8
1 parent 2c25de7 commit b4dc295

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

code/python/example.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33

44
from neo4j import GraphDatabase, basic_auth
55

6-
driver = GraphDatabase.driver(
7-
"neo4j+s://demo.neo4jlabs.com:7687",
8-
auth=basic_auth("mUser", "s3cr3t"))
9-
106
cypher_query = '''
117
MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
128
'''
139

14-
with driver.session(database="movies") as session:
15-
results = session.read_transaction(
16-
lambda tx: tx.run(cypher_query,
17-
movieTitle="The Matrix").data())
18-
for record in results:
19-
print(record['actorName'])
20-
21-
driver.close()
10+
with GraphDatabase.driver(
11+
"neo4j+s://demo.neo4jlabs.com:7687",
12+
auth=("mUser", "s3cr3t")
13+
) as driver:
14+
result = driver.execute_query(
15+
cypher_query,
16+
movieTitle="The Matrix",
17+
database_="movies")
18+
for record in result.records:
19+
print(record['actorName'])

0 commit comments

Comments
 (0)