Python连接neo4j远程批量删除数据

1.neo4j少量数据可直接删除

graph = Graph("http://localhost:7474", username="neo4j", password='neo4j')
graph.delete_all()

2.neo4j千万级数据则分批进行删除

graph = Graph("http://localhost:7474", username="neo4j", password='neo4j')
cypher = "CALL apoc.periodic.commit(         'MATCH (n) WITH n LIMIT $limit DELETE n RETURN count(*)',         {limit: 10000}       )       YIELD updates, executions, runtime, batches       RETURN updates, executions, runtime, batches;"
data = graph.run(cypher).data()
print(data)

原因:neo4j目前一次性删除千万级大量数据会导致内存溢出异常,因此可分批进行删除
说明:python分批删除方式调用neo4j连接函数进行连接,然后以apoc.periodic.commit()存储过程的方式调用cypher语句进行批量删除

参考链接:
https://www.cnblogs.com/liangxinxinbo/p/13469623.html
https://blog.csdn.net/yihuliunian/article/details/90637996
https://blog.csdn.net/GraphWay/article/details/93711343

你可能感兴趣的:(个人总结,neo4j,批量删除,apoc存储过程)