ly-ue4-backend / nebula-console

Command line interface for the Nebula Graph service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nebula Graph Console

This repository contains the Nebula Graph Console for Nebula Graph 2.0. Nebula Graph Console (Console for short) is a console for Nebula Graph. With Console, you can create a graph schema, import the demonstration nba dataset, and retrieve data.

Features

  • Supports interactive and non-interactive mode.
  • Supports viewing the history statements.
  • Supports autocompletion.
  • Supports multiple OS and architecture (We recommend Linux/AMD64).

How to Install

From Source Code

  1. Build Nebula Graph Console

    To build Nebula Graph Console, make sure that you have installed Go.

    NOTE: Go version provided with apt on ubuntu is usually "outdated".

    Run the following command to examine if Go is installed on your machine.

    $ go version

    The version should be newer than 1.13.

    Use Git to clone the source code of Nebula Graph Console to your host.

    $ git clone https://github.com/vesoft-inc/nebula-console

    Run the following command to build Nebula Graph Console.

    $ cd nebula-console
    $ make

    You can find a binary named nebula-console.

  2. Connect to Nebula Graph

    To connect to your Nebula Graph services, use the following command.

    $ ./nebula-console -addr <ip> -port <port> -u <username> -p <password>
        [-t 120] [-e "nGQL_statement" | -f filename.nGQL]
    Option Description
    -h Shows the help menu.
    -addr/-address Sets the IP/HOST address of the graphd service.
    -P/-port Sets the port number of the graphd service.
    -u/-user Sets the username of your Nebula Graph account. See authentication.
    -p/-password Sets the password of your Nebula Graph account.
    -t/-timeout Sets an integer-type timeout threshold for the connection. The unit is second. The default value is 120.
    -e/-eval Sets a string-type nGQL statement. The nGQL statement is executed once the connection succeeds. The connection stops after the result is returned.
    -f/-file Sets the path of an nGQL file. The nGQL statements in the file are executed once the connection succeeds. You'll get the return messages and the connection stops then.

    E.g.,

    $./nebula-console -addr=192.168.10.111 -port 9669 -u root -p nebula
    2021/03/15 15:21:43 [INFO] connection pool is initialized successfully
    Welcome to Nebula Graph!

    Check options for ./nebula-console -h:

    • try ./nebula-console in interactive mode directly.

    • And try ./nebula-console -e 'show hosts' for the direct script mode.

    • And try ./nebula-console -f demo.nGQL for the script file mode.

From Binary

  • Download the binaries on the Releases page

  • Add execute permissions to the binary

  • Connect to your Nebula Graph services:

$ ./<$YOUR_BINARY> -addr <ip> -port <port> -u <username> -p <password>
        [-t 120] [-e "nGQL_statement" | -f filename.nGQL]

Docker

Create a container:

$ docker run --rm -ti --network nebula-docker-compose_nebula-net --entrypoint=/bin/sh vesoft/nebula-console:v2-nightly

To connect to your Nebula Graph services, run the follow command in the container:

docker> nebula-console -u <user> -p <password> --address=<graphd> --port=9669

Export mode for Nebula Graph Console

When the export mode is enabled, Nebula Graph Console exports all the query results into a CSV file. When the export mode is disabled, the export stops. The syntax is as follows.

NOTE: The following commands are case insensitive.

  • Enable nebula-console export mode:
nebula> :set CSV <your_file.csv>
  • Disable nebula-console export mode:
nebula> :unset CSV

Load nba dataset

To load the demonstration nba dataset, make sure that Console is connected to Nebula Graph.

nebula> :play nba
Start loading dataset nba...

Load dataset succeeded!

Wait for heartbeat

nebula> :sleep 3

e.g.

cat >> nba.ngql << EOF
CREATE SPACE nba(VID_TYPE=FIXED_STRING(32));
:sleep 3

USE nba;
CREATE TAG IF NOT EXISTS player(name string, age int);
:sleep 3

INSERT VERTEX player(name, age) VALUES "Amar'e Stoudemire": ("Amar'e Stoudemire", 36)
EOF

nebula-console -addr 127.0.0.1 -port 9669 -u root -p nebula -f nba.ngql

Export .dot file

To export the graviz text to a .dot format, run the following command:

nebula> :set dot <filename>

For example:

nebula> TODO

Disconnect Nebula Graph Console from Nebula Graph

You can use :EXIT or :QUIT to disconnect from Nebula Graph. For convenience, nebula-console supports using these commands in lower case without the colon (":"), such as quit.

nebula> :QUIT

Bye root!

nebula> :EXIT

Bye root!

nebula> quit

Bye root!

nebula> exit

Bye root!

Keyboard Shortcuts

Key Binding Description
Ctrl-A, Home Move cursor to beginning of line
Ctrl-E, End Move cursor to end of line
Ctrl-B, Left Move cursor one character left
Ctrl-F, Right Move cursor one character right
Ctrl-Left, Alt-B Move cursor to previous word
Ctrl-Right, Alt-F Move cursor to next word
Ctrl-D, Del (if line is not empty) Delete character under cursor
Ctrl-D (if line is empty) End of File --- quit from the console
Ctrl-C Reset input (create new empty prompt)
Ctrl-L Clear screen (line is unmodified)
Ctrl-T Transpose previous character with current character
Ctrl-H, BackSpace Delete character before cursor
Ctrl-W, Alt-BackSpace Delete word leading up to cursor
Alt-D Delete word following cursor
Ctrl-K Delete from cursor to end of line
Ctrl-U Delete from start of line to cursor
Ctrl-P, Up Previous match from history
Ctrl-N, Down Next match from history
Ctrl-R Reverse Search history (Ctrl-S forward, Ctrl-G cancel)
Ctrl-Y Paste from Yank buffer (Alt-Y to paste next yank instead)
Tab Next completion
Shift-Tab (after Tab) Previous completion

TODO

  • CI/CD
  • batch process to reduce memory consumption and speed up IO

About

Command line interface for the Nebula Graph service

License:Apache License 2.0


Languages

Language:Go 96.5%Language:Makefile 2.6%Language:Dockerfile 0.9%