neoblade11
neoblade11

Reputation: 19

py2neo v4 create a relationship with 2 existing node in database

i have this problem

With py2neo how can I create a relationship between 2 existing nodes in my database select them using the id. In the py2neo documentation I find only examples that create the nodes at the moment and associate them directly with merge

I try this in my code:

db = conn()
data = DataFrame(db.run("MATCH (n:personalesanitario) RETURN ID(n) LIMIT 100").data())
x = 0
WORKIN = Relationship.type("WORKIN")
while (x <= 99):
    #print(data['ID(n)'][x])
    n1 =  db.evaluate("MATCH (n:personalesanitario) WHERE ID(n) = $id RETURN 1",parameters = {'id':int(data['ID(n)'][x])})
    print(n1)
    n2 = db.evaluate("MATCH (n:reparti) WHERE ID(n) = $id RETURN 1",parameters = {'id':randint(101,109)})
    #print(n2)
    db.merge(WORKIN(n1,n2))
    x = x+1

Upvotes: 0

Views: 537

Answers (1)

Rajendra Kadam
Rajendra Kadam

Reputation: 4052

Change return 1 to Return n in those two queries.

It's not returning node but string.

Upvotes: 1

Related Questions