NEO4J-CLIENT(1) | General Commands Manual | NEO4J-CLIENT(1) |
neo4j-client - command shell for Neo4j
neo4j-client [options...] [URL | host[:port]]
neo4j-client is a command shell for Neo4j. It supports secure connections to Neo4j server, sending of statements (including multiline statements), persistent command history, and rendering of results to tables or CSV.
neo4j-client requires Neo4j Server version 3.0 or later.
By default, history is saved to $(HOME)/.neo4j/client-history.
The username (and password) can also be supplied in the connection URL, and will override what is set here.
The password (and username) can also be supplied in the connection URL, and will override what is set here.
By default, the file is $(HOME)/.neo4j/neo4j_known_certs.
A URL may be specified on the command line, and will cause neo4j-client to attempt to connect to the specified server immediately. The URL is of the form neo4j://host[:port], and specifies the host and port the Neo4j server is listening on.
When neo4j-client is started with standard input connected to an interactive terminal, it will run in interactive mode. This will present a command prompt to the user and will evaluate each command as it is entered. The history of entered commands will be saved (unless disabled) and an errors in evaluation will be presented to the user. Results from statements sent to Neo4j will be presented to the user in table format (by default), using the full width of the terminal.
When neo4j-client is started with standard intput connected to a pipe, or when the --source/-i argument is specified, statements will be read from the pipe or the specified file(s). Any error in evaluation will cause neo4j-client to terminate without evaluating any further input. By default, results will be output in CSV format, although this may be changed using :set format=(csv|table).
Once started, commands and statements can be entered at the neo4j-client prompt. Commands always begin with a colon (:) and conclude at the end of the line, e.g. :help, and are evaluated by neo4j-client rather than being sent to the Neo4j server. Statements do not begin with a colon (:), may span multiple lines, are terminated with a semi-colon (;) and will be sent to the Neo4j server for evaluation.
neo4j-client understands a variety of commands, including:
Note that all parameters are sent to the server for every query, so it is best not to export large values without immediately using :unexport after.
Equivalent to `:set format=(table|csv)`.
Equivalent to `:set width=<n>`.
Start neo4j-client in interactive mode, and run a query:
$ neo4j-client -u neo4j localhost
Password: *****
neo4j> MATCH (n:Person) RETURN n.name, n.born LIMIT 4;
+-----------------------------+-----------------------------+
| n.name | n.born |
+-----------------------------+-----------------------------+
| Keanu Reeves | 1964 |
| Carrie-Anne Moss | 1967 |
| Laurence Fishburne | 1961 |
| Hugo Weaving | 1960 |
+-----------------------------+-----------------------------+
neo4j> :quit
$
Evaluate a query in non-interactive (batch) mode, saving the output to a csv file:
$ echo "MATCH (n:Person) RETURN n.name, n.born LIMIT 4;" | \
neo4j-client -u neo4j -P localhost > result.csv
Password: *****
$
$ cat result.csv
"n.name","n.born"
"Keanu Reeves",1964
"Carrie-Anne Moss",1967
"Laurence Fishburne",1961
"Hugo Weaving",1960
$
Evaluate a source file, and save the output:
$ neo4j-client -u neo4j -p pass -o result.csv -i query.cyp
$
$ cat query.cyp
MATCH (n:Person) RETURN n.name, n.born LIMIT 4;
$
$ cat result.csv
"n.name","n.born"
"Keanu Reeves",1964
"Carrie-Anne Moss",1967
"Laurence Fishburne",1961
"Hugo Weaving",1960
$
In interactive mode, neo4j-client attempts to exit cleanly (with $? set to 0) when the session is terminated via the use of :quit, :exit or ctrl-D, and to use a non-zero exit code otherwise. In non-interactive (batch) mode, neo4j-client will exit cleanly if all statements read from stdin evaluate successfully.
This man page is current for version 2.2.0 of neo4j-client.
http://www.apache.org/licenses/LICENSE-2.0
Chris Leishman (http://github.com/cleishm)