-1

I have the following code:

for t in set(tags):
    new_tag = Node('Tag', name=t)
    tag = graph.merge(new_tag, 'Tag', 'name')
    rel = Relationship(tag, 'TAGGED', post)
    graph.create(rel)

The problem is that graph.merge() is returning None, but documentation says it would crate a new node if no matches are found.

This is the error I get when graph.create(rel) is executed:

 File "/Users/hugovillalobos/Documents/Code/FlaskrGraphProject/FlaskrGraphVenv/lib/python3.7/site-packages/py2neo/internal/operations.py", line 134, in <genexpr>
    for labels, nodes in _node_create_dict(n for n in subgraph.nodes if n.graph is None).items():
AttributeError: 'NoneType' object has no attribute 'graph'
Sukhi
  • 13,261
  • 7
  • 36
  • 53
HuLu ViCa
  • 5,077
  • 10
  • 43
  • 93

2 Answers2

0

commit after merging. And then create the relationship.

Prakashreddy
  • 1
  • 1
  • 2
0

You should simply use:

tag = graph.merge(new_tag)