3

So i have an array already defined and want to create relationship between the array objects and the nodes already created using python py2neo model ( i am using loop ), but i am unable to do so. the outcome is the relationship keeps on getting overwritten and finally only the last iterating object and its relationship exist

y = ['D','E']
b= ['C1','C2']
for x in y:
    for a in b:
        tx1=graph.begin()
        tempnode = D()
        tempnode.cluster = True
        tempnode.name=str(x)
        host_node_to_point_to1=C.match(graph,str(a)).first()
        tempnode.linkedto.update(host_node_to_point_to1)
        tx1.merge(tempnode)
        tx1.commit()

Output Expected and ActualOutput Expected and Actual

Nouman Ch
  • 4,023
  • 4
  • 29
  • 42

0 Answers0