我有以下代码:
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)
问题是graph.merge()
返回None
,但是documentation说如果找不到匹配项,它将创建一个新节点。
这是执行graph.create(rel)
时遇到的错误:
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'
答案 0 :(得分:0)
答案 1 :(得分:0)
您应该简单地使用:
tag = graph.merge(new_tag)