Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-02-2021 12:37 AM
considered I run below query in neo4j browser. It will shows some nodes in neo4j display panel and how many nodes and relationships in this query have.
I wish to get the "nodes count and relationship" count when i execute the query in python way.
query:
match(n) return(n) limit 5
results of query in the browser shows : "Displaying 5 nodes, 1 relationships"
I am using python3.5 and module as "from neo4j import GraphDatabase"
09-02-2021 01:59 PM
When you execute the Cypher query with the python driver, call the consume() method on the result object like so:
https://neo4j.com/docs/api/python-driver/current/api.html#neo4j.Result.consume
Then I believe you can use the "counters" member of that object that comes back; see SummaryCounters in the API here
https://neo4j.com/docs/api/python-driver/current/api.html#neo4j.ResultSummary
09-03-2021 03:54 AM
Thanks david.allen,
i tried the below code. But i got '{}'.
from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://0.0.0.0:7687", auth=("neo4j", "xxxx"))
session = driver.session()
q1="MATCH(n) return n limit 5"
nodes = session.run(q1)
print(nodes.consume().counters)
All the sessions of the conference are now available online