Search code examples
pythonneo4jcypherpy2neo

Retrieve NodePointer.properties that was not inserted into DB yet


I'm using py2neo to insert some data into my neo4j db.

I create arrays of NodePointers and Relations and insert them with

for i in rels:
    test_graph.create(i)

after the process.

During the creation of my arrays I would like to check if a specific NodePointer was already added to the array or not (don't want to create two NodePointers with same name).

Looking for a way to check a NodePointer properties, I've found this at py2neo documentation:

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

but when I try to do:

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)    

I get: 'NodePointer' object has no attribute 'labels'

Does anyone have a solution or suggestion for my problem? Thank you.


Solution

  • The problem was in the (mVar == False) comparison. Even though the error was raised at the .properties["name"] line.