Hello,
I an doing the Graph Academy Course for Python Apps. Setting the environmental variables and building the connection went well.
But now I am struggling with read_transaction: In the following code the variable res1 is None (so nothing is printed), while res2 contains the names of the proper actors.
#Create a new Driver instance
driver = GraphDatabase.driver(neo4j_uri, auth=(neo4j_username, neo4j_password))
#Execute within a Read Transaction vs execute with session.run()
with driver.session() as session:
def get_movies(tx, title):
return tx.run("""
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE m.title = $title
RETURN p.name AS name
LIMIT 10
""", title=title)
res1 = session.read_transaction(get_movies,title="Apollo 13")
for r in res1:
print(r["name"])
res2 = session.run("""
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE m.title = $title
RETURN p.name AS name
LIMIT 10
""", title="Apollo 13")
for r in res2:
print(r["name"])
session.close()
Does anybody know where I am going wrong here?
Thanks in advance