TuGraph console client
lgraph_cli
is a console client based on the bolt protocol, written in c++, which requires a connection to tugraph’s bolt port.
lgraph_cypher
is a console client based on http, written in python, which requires a connection to tugraph’s http port.
lgraph_cypher
needs some python libraries to be installed.
lgraph_cli
is a binary executable file that has no dependencies on other dynamic libraries and can be executed by copying it to a linux server.
lgraph_cli
The statement ends with a semicolon, type exit
, quit
or Ctrl-C to exit the client.
lgraph_cli --ip 127.0.0.1 --port 7687 --graph default --user admin --password 73@TuGraph
Welcome to the TuGraph console client. Commands end with ';'.
Copyright(C) 2018-2023 Ant Group. All rights reserved.
Type 'exit', 'quit' or Ctrl-C to exit.
TuGraph> match(n) return n limit 1;
+-------------------------------------------------------------------------------------------------------------------------------------+
| n |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:2,born:1961,poster_image:"https://image.tmdb.org/t/p/w185/mh0lZ1XsT84FayMNiT6Erh91mVu.jpg",name:"Laurence Fishburne"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
TuGraph>
The statement can be inputed on more than one line.
TuGraph> match(n)
-> return n
-> limit 1;
+-------------------------------------------------------------------------------------------------------------------------------------+
| n |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:2,born:1961,poster_image:"https://image.tmdb.org/t/p/w185/mh0lZ1XsT84FayMNiT6Erh91mVu.jpg",name:"Laurence Fishburne"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
TuGraph>
non-interactive
echo "match(n) return n limit 1;" | lgraph_cli --ip 127.0.0.1 --port 7687 --graph default --user admin --password 73@TuGraph
+-------------------------------------------------------------------------------------------------------------------------------------+
| n |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:2,born:1961,poster_image:"https://image.tmdb.org/t/p/w185/mh0lZ1XsT84FayMNiT6Erh91mVu.jpg",name:"Laurence Fishburne"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
1 rows
read statements from file
cat query.txt
match(n) return n limit 1;
match(n) return n limit 1;
lgraph_cli --ip 127.0.0.1 --port 7687 --graph default --user admin --password 73@TuGraph < query.txt
+-------------------------------------------------------------------------------------------------------------------------------------+
| n |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:2,born:1961,poster_image:"https://image.tmdb.org/t/p/w185/mh0lZ1XsT84FayMNiT6Erh91mVu.jpg",name:"Laurence Fishburne"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:3,born:1967,poster_image:"https://image.tmdb.org/t/p/w185/8iATAc5z5XOKFFARLsvaawa8MTY.jpg",name:"Carrie-Anne Moss"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
2 rows
+-------------------------------------------------------------------------------------------------------------------------------------+
| n |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:2,born:1961,poster_image:"https://image.tmdb.org/t/p/w185/mh0lZ1XsT84FayMNiT6Erh91mVu.jpg",name:"Laurence Fishburne"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
| (:person {id:3,born:1967,poster_image:"https://image.tmdb.org/t/p/w185/8iATAc5z5XOKFFARLsvaawa8MTY.jpg",name:"Carrie-Anne Moss"}) |
+-------------------------------------------------------------------------------------------------------------------------------------+
2 rows
online export
lgraph_cli supports streaming read, so just redirect the output to a file. The output format supports csv and json
csv
echo "match(n) return n.id, n.name;" | lgraph_cli --ip 127.0.0.1 --port 7687 --graph default --user admin --password 73@TuGraph --format csv > output.txt
json
echo "match(n) return n.id, n.name;" | lgraph_cli --ip 127.0.0.1 --port 7687 --graph default --user admin --password 73@TuGraph --format json > output.txt