neo4j-client 是 Neo4j 的命令行 shell (CLI)。它支持与 Neo4j 服务器的安全连接,发送语句(包括多行语句)、持久命令行历史记录以及将结果渲染成表或 CSV。
neo4j-client 使用 Bolt 网络协议,并可在任何支持 Bolt 的服务器上工作。
环境要求:
neo4j-client 可在 GNU/Linux, Mac OS X 和 FreeBSD 平台上运行,需要 neo4j 3.0.0 或更高版本。
neo4j-client 的用法
Example interactive usage:
$ neo4j-client -u neo4j localhost The authenticity of host 'localhost:7687' could not be established. TLS certificate fingerprint is ded0fd2e893cd0b579f47f7798e10cb68dfa2fd3bc9b3c973157da81bab451d74f9452ba99a9c5f66dadb8a360959e5ebd8abb2d7c81230841e60531a96d268. Would you like to trust this host (NO/yes/once)? yes Password: ***** neo4j> :help Enter commands or cypher statements at the prompt. Commands always begin with a colon (:) and conclude at the end of the line, for example `:help`. 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. Available commands: :quit Exit the shell :connect '<url>' Connect to the specified URL :connect host [port] Connect to the specified host (and optional port) :disconnect Disconnect the client from the server :export Display currently exported parameters :export name=val ... Export parameters for queries :unexport name ... Unexport parameters for queries :reset Reset the session with the server :set Display current option values :set option=value ... Set shell options :unset option ... Unset shell options :status Show the client connection status :help Show usage information :format (table|csv) Set the output format :width (<n>|auto) Set the number of columns in the table output For more information, see the neo4j-client(1) manpage. neo4j> neo4j> :status Connected to 'neo4j://neo4j@localhost:7687' neo4j> neo4j> MATCH (n:Person) RETURN n LIMIT 3; +----------------------------------------------------------------------------+ | n | +----------------------------------------------------------------------------+ | (:Person{born:1964,name:"Keanu Reeves"}) | | (:Person{born:1967,name:"Carrie-Anne Moss"}) | | (:Person{born:1961,name:"Laurence Fishburne"}) | +----------------------------------------------------------------------------+ neo4j> neo4j> :set echo=off // echo non-interactive commands before rendering results insecure=no // do not attempt to establish secure connections format=table // set the output format (`table` or `csv`). outfile= // redirect output to a file username="neo4j" // the default username for connections width=auto // the width to render tables (`auto` for term width) neo4j> neo4j> :quit $
Example non-interactive usage:
$ echo "MATCH (n:Person) RETURN n.name AS name, n.born AS born LIMIT 3" | \ neo4j-client -u neo4j -P localhost > result.csv Password: ***** $ $ cat result.csv "name","born" "Keanu Reeves",1964 "Carrie-Anne Moss",1967 "Laurence Fishburne",1961 $