cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Python neo4j driver to return the selected cypher query nodes and relationships in graph format

I tried to use below code snippet to read the query result which should return all 
nodes and respective all relationships

result = session.run(query, param)
print(result.graph().relationships.items())
print(result.graph().nodes.items())

Can you anyone help me to return the result so I come to know properly,
using python 3.10 and neo4j 5 version along neo4j python driver.

#python #neo4j #pythondriver #cypher
2 REPLIES 2

Note, the result of calling ‘relationships’ is a set of relationships. Similarly, ‘nodes’ returns a set of nodes. As such, you have to iterate over each set and apply ‘items()’ to each set element. 

maheshwar_ligad
Node Clone

@glilienfield can you give some sample code snippet? because when I try I didnt find anything in the documentation as such