Python neo4j driver to return the selected cypher query nodes and relationships in graph format
‎11-15-2022 11:06 PM
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
‎11-16-2022 02:10 AM
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.
‎11-16-2022 03:11 AM - edited ‎11-16-2022 03:18 AM
@glilienfield can you give some sample code snippet? because when I try I didnt find anything in the documentation as such