簡體   English   中英

py2neo 合並返回無

[英]py2neo merge is returning None

我有以下代碼:

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 ,但文檔說如果找不到匹配項,它將創建一個新節點。

這是我在執行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'

合並后提交。 然后建立關系。

你應該簡單地使用:

tag = graph.merge(new_tag)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM