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.

Dumping an entire node in json with python

Hi, this is my first post, I've been picking up Neo4j a lifetime of standard DB and I am stuck at a probleme that I can't solve. I've tried going through the forum but I have yet to find a solution

I am required to dump an entire node into a file (format not important, could be csv or json) and this is my code which is a basic Match all:

def get_node(self, node_name):
    with self.driver.session() as session:
        result = session.read_transaction(self._find_and_return_node, node_name)
        i=0
        for record in result:
            i+=1
            print("Found record {i} : {record}".format(record=record,i=i))
            data = record["end_date"]
            print(data)
            #print("Detail : {record}".format(record=record.properties, i=i))

@staticmethod
def _find_and_return_node(tx, node_name):

    query = (
        "MATCH (n:"+node_name+") RETURN n AS name"
    )
    result = tx.run(query).data()
    return [record["name"] for record in result]

This works when the node is small (around 5000 elements). However, for huge nodes (100k elements ), my script fails miserably and rage quits after awhile. (no error, just a SIGKILL). Is there another way to accomplish what I set out to do? Am I missing something.

2 REPLIES 2

andreperez
Graph Buddy

Hello, try apoc.periodic methods. It allows your query to be processed in batches.

Also you should try using EXPLAIN query method to understand the resources your query is utilizing and verify your debug log to verify any other errors.

I see, I'll try that and see, thank you