How to execute Cypher in a file?

I work on windows. I created a Cypher request text file using notepad. How to run a query in a file using the Neo4jShell or Neo4j web console console.

+13
neo4j cypher
source share
6 answers

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

On windows, it will look like this:

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

Or you can also print the result to a new file

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

I am also sure that there is a way to do this from the shell, and not at startup, as Stefan Armbruster once demonstrated to me, but for God's sake, I can’t remember how he did it. But this approach also works.

+8
source share

For Debian / Ubuntu or any * nix installations, use the following terminals:

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

Note that each cypher request in a file must end with a semicolon and must be separated by an empty line from another request. In addition, ending .cql (file format) is optional.

+13
source share
 $ neo4j-shell -file query.cql 

or using cypher-shell

 $ cat query.cql | cypher-shell 
+5
source share

The neo4jShell.bat file was deleted after asking this question. A new approach to executing cypher files is to use a web application called LazyWebCypher .

+4
source share

With the Neo4j web interface, I just copy and paste.

On the console, I sometimes use curl to talk to the Neo4j REST interface. This allows me to use the same queries (with links to individual parameters) that I have in my application. You must wrap the request in your file in a json object for this.

data.json:

 { "query":"match (u:User) where u.username={username} return u", "params":{"username":"trenkerbe"} } 

Team:

 curl -i -X POST -H "Content-Type: application/json" -d @data.json http://localhost:7474/db/data/cypher 
+2
source share

./bin/neo4j-shell -path ../ data / databases / -c <commands.cql

on Neo4j 3.2.1

0
source share

All Articles