I want to create relationship between nodes and relationship label should be assigned from a variable value. I am using GraphDatabase module from neo4j plugin for python for connecting to neo4j.
ex.
def create_relationships(tx):
result = tx.run("MATCH (a:NodeType1), (b:NodeType2)"
"MERGE (a)-[r:$related]->(b)"
"RETURN r", related = getLabelForRelationship())
return result
Basically for any relation creation (a)-[:related]-(b), related string is not fixed so instead of string related I want to use a variable. Is this possible? Can someone please help me with this?
Thanks a lot @koji, I was passing related variable as an argument to tx.run function so it did not work earlier. Now I treated it as separate variable as you have shown and it worked!