Skip to content

Instantly share code, notes, and snippets.

@jstenquist
Created January 19, 2023 18:35
Show Gist options
  • Save jstenquist/429759a7780ce8c5ba33f215c6721ee8 to your computer and use it in GitHub Desktop.
Save jstenquist/429759a7780ce8c5ba33f215c6721ee8 to your computer and use it in GitHub Desktop.
Neo4j - Database export script for Graphene
from neo4j import GraphDatabase
# Connect to the Neo4j database
driver = GraphDatabase.driver("neo4j+s://XXXXXXXXXX.graphenedb.com:24786", auth=("neo4j", "PASSWORD"))
session = driver.session()
# Export the database to a file in GraphML format
with open("export.graphml", "w") as file:
result = session.run("CALL apoc.export.graphml.query('MATCH (n) RETURN n', '', {})")
file.write(result.single()[0])
# Close the session
session.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment