Article DetailsDetailsHelp DetailsTo export your query results from an AuraDB Instance to a file simply via command line, you can use Neo4j Cypher Shell and make the calls from the a shell (here we use bash). Method The basic idea behind exporting your query results to a file is to use Cypher Shell to export a Stream along with a redirect to redirect the output to a file. You can choose to store the query you need to run in a file or in a variable. It is recommended to store the query in a file. Cypher Shell will automatically use credentials stored in the environment variables: NEO4J_USERNAMENEO4J_PASSWORD Note: If you wish to specify the credentials as part of the command instead of using the default environment variables you can do so using the -u and -p flags for Username and Password respectively. For more information on Cypher Shell, please see the documentation and How do I authenticate with cypher-shell without specifying the username and password on the command line ? The query file or variable can then be passed to the Cypher Shell as below: # You can pass in the query to the Cypher Shell like below, you can also do so with a file, using cat, type or echo followed by | similar to below. The dbid will need changing to the id of your AuraDB Instance cat $CQL | cypher-shell --format plain -a neo4j+s://dbid.databases.neo4j.io > results.file The redirect ">" from stdout is to ensure this is captured to file.Depending on your output you may be also interested in: How to handle special chars with cypher-shell output ?using cypher-shell to stream cypher statement results to local file in JSON format Exporting to GraphML Below is an example file showing how to use the apoc.export.graphml.query procedure: WITH "MATCH (a)-[:ACTED_IN]->(m) RETURN (a)-[]->(m)" as query CALL apoc.export.graphml.query(query, "", {stream:true}) YIELD file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data RETURN file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data; After the WITH clause, between double quotes, write the query you need the results from. This query will be passed to the apoc.export.graphml.query procedure as the first argument. The second argument is a blank string, this would usually be the file name to export to but in this case we must export to a stream so a blank string is necessary. Omitting the parameter entirely will cause an error to be thrown. The final argument tells the procedure to export the information as a stream. For further information on how this procedure works, please see: https://neo4j.com/labs/apoc/4.4/overview/apoc.export/apoc.export.graphml.query/ Using a file called cql.query to store the query located in our working directory, the below shows how to run the query and redirect the result stream to a file: #!/bin/bash # Pass the created file to the cypher shell, using cat filename followed by | . Change dbid to the id of your AuraDB Instance cat cql.query | cypher-shell --format plain -a neo4j+s://dbid.databases.neo4j.io > results.graphml InformationTitleExporting query results to a file from an AuraDB Instance using Cypher ShellArticle Created Date3/15/2024, 10:57 PMURL Name6259960898835-Exporting-query-results-to-a-file-from-an-AuraDB-Instance-using-Cypher-ShellLast Modified Date4/27/2024, 4:00 PM