检索尚未插入到DB中的NodePointer.properties

时间:2016-03-30 10:03:19

标签: python neo4j cypher py2neo

我正在使用py2neo将一些数据插入我的neo4j数据库。

我创建了NodePointers和Relations的数组,并用

插入它们
for i in rels:
    test_graph.create(i)

过程结束后。

在创建数组期间,我想检查特定的NodePointer是否已经添加到数组中(不想创建两个具有相同名称的NodePointers)。

正在寻找一种检查NodePointer属性的方法,我在py2neo文档中找到了这个:

>>> alice.properties["name"]
'Alice'

但是当我尝试做的时候:

def isThereAThisInHere(this, here):
    for i in here:
        if (i.properties["name"] == this):
            return i
    return False    

mVar = isThereAThisInHere(defWord.wordVar[0],tempVar)
if (mVar == False):
    mVar = Node("Variable",name=defWord.wordVar[0])
    tempVar.append(mVar)    

我得到:'NodePointer' object has no attribute 'labels'

有没有人对我的问题有解决方案或建议?谢谢。

1 个答案:

答案 0 :(得分:0)

问题出在(mVar == False)比较中。尽管错误是在.properties["name"]行提出的。