How to execute Cypher in a file?

On Debian/Ubuntu or any *nix installations, use the following from terminal:

$ neo4j-shell -c < path-to-cypher-query-file.cql

Note that each cypher query in the file must end in a semicolon and must be separated by a blank line from the other query. Also, the .cql ending (file format) is not mandatory.


Just add -file as a parameter when starting the console.

On windows, it would look like this :

Neo4jShell.bat -file path/to/cql/file 

Or you could also print the result into a new file

Neo4jShell.bat -file path/to/cql/file > path/to/output/file

I'm also sure there is a way to do it from within the shell and not at startup, as it was once demonstrated to me by Stefan Armbruster but for the love of god, I can't remember how he did it. But this approach works as well.

Tags:

Neo4J

Cypher