Skip to content

Latest commit

 

History

History
102 lines (73 loc) · 5.55 KB

6.bolt-console-client.md

File metadata and controls

102 lines (73 loc) · 5.55 KB

TuGraph console client

lgraph_cli 是基于bolt协议的 console client,c++编写,使用时需要连接tugraph的bolt端口。

lgraph_cli 是一个二进制的可执行文件,不依赖其他动态库,拷贝到一台linux机器上就可执行。

lgraph_cli使用

语句以分号结束,输入exit, quit或者Ctrl-C退出客户端。

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>

语句可以中间换行,多行输入。

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>

非交互式

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

从文件读取多条命令

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

在线数据导出

lgraph_cli 支持流式读取,导出数据只需要把lgraph_cli的输出重定向到文件中即可,导出格式支持csv和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