Search code examples
py2neo

How to retrieve property values of a node in py2neo


I,m creating a graph database of geometric shapes and nodes contain a property called "type" to indicate whether that shape is a Triangle, Circle or square.I want to retrieve the type of every node and use it in IF condition as follow.

Results = g.run("START n=node(*)  RETURN n.type as type")
for Result in Results:
     if Result.type == 'TRINGLE':
        print("It is a Triange")
     elif Result.type == 'CIRCLE':
         print("It is a Circle")
     else:
        print("It is a Square")

when run this code it is showing an error like this- if Result.type == 'TRINGLE': AttributeError: 'Record' object has no attribute 'type'

can anyone please tell me that are there any way to solve this.


Solution

  • You need record["type"] instead of record.type.