someguy
someguy

Reputation: 13

CypherResults py2neo get node object

i need to get the id of a node in neo4j using py2neo. using the following query i am getting a cypher result object which contains a record object

table_query = neo4j.CypherQuery(db, "merge (x: Table{name: 'table_param'}) return x")

the contents of the .data method are equal to the following [Record(x=Node('host/db/data/node/31'))]

how can i get the node object

Upvotes: 0

Views: 1809

Answers (1)

Martin Preusse
Martin Preusse

Reputation: 9369

CypherQuery gives you a CypherResults object if you .execute() it or an IterableCypherResult object if you .stream() it.

You can then iterate over the result object:

table_query = neo4j.CypherQuery(db, "merge (x: Table{name: 'table_param'}) return x")
results = table_query.execute()

for r in results:
    # get the node you return in your query
    my_node = r[0]
    # get the properties of your node
    props = my_node.get_properties()

Upvotes: 1

Related Questions