Hi,
I am using python to populate and drop data on neo4j with neo4j-python.
While dropping the nodes, I'm running a query like:
call apoc.periodic.iterate("MATCH (n {data_source:'APAC'})
return n", "DETACH DELETE n", {batchSize:10000})
yield batches, total return total AS count
Which is being called via this Neo4jDriver class:
class Neo4JDriver:
def __init__(self, url, user, password, encrypted=False):
self._driver = GraphDatabase.driver(url, auth=(user, password), encrypted=encrypted)
def close(self):
self._driver.close()
def exec_cypher_query(self, query):
logger.info("Firing query :: {}".format(query))
with self._driver.session() as session:
return session.run(query)
The query runs fine and does it job, but when I try to retrieve the 'count' from the Result object as in the following query:
result = exec_cypher_query(query)
But I cannot find the value of count in the result variable. I have debugged the code, and trying to follow many suggestions available in different forums, but for no success.
Earlier, I was using query:
MATCH (n {label} {props})
DETACH DELETE n
RETURN COUNT(n) as count
After which I used to get the number of deleted nodes using:
if 'stats' in result._metadata:
count = result._metadata['stats']['nodes-deleted']
But this does not seem to working using the new query for batch wise delete.
Please suggest some way to get the count of nodes getting deleted. I'm really stuck,
Thanks. Cheers.