I wrote a function in python using dynamically computed property names and parameters to write a cypher query in order to retrieve a path from Recon2Neo4j database (The Neo4j-based metabolic framework is freely available from: https://diseaseknowledgebase.etriks.org/metabolic/browser/.). The match query without parameters works perfectly in the Neo4j browser for specific property names and values. I wonder if the following code can really work. There is no error, but the "print(p1, p1val, p2, p2val)" never executes. Thank you.
def getPath(p1, p1val, p2, p2val):
with driver.session() as session:
with session.begin_transaction() as tx:
for record in tx.run("WITH $p1 AS propnam1, $p2 AS propnam2 "
"MATCH p = shortestPath((m1)-[*..]-(m2)) "
"WHERE m1[propnam1]=$p1val AND m2[propnam2]=$p2val "
"RETURN p", p1=p1, p1val=p1val, p2=p2, p2val=p2val):
print(p1, p1val, p2, p2val)
print(record["p"])
session.close()
#return result