【问题标题】:py2neo merge is returning Nonepy2neo 合并返回无
【发布时间】:2019-08-07 03:28:20
【问题描述】:

我有以下代码:

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'

【问题讨论】:

    标签: python neo4j py2neo


    【解决方案1】:

    合并后提交。然后创建关系。

    【讨论】:

      【解决方案2】:

      你应该简单地使用:

      tag = graph.merge(new_tag)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多