# Tugraph CLI > This document mainly introduces the CLI tool lgraph_cypher of TuGraph. ## 1.Instructions The TuGraph release comes with a query client named 'lgraph_cypher' that can be used to submit OpenCypher requests to the TuGraph server. The 'lgraph_cypher' client has two execution modes: single command mode and interactive mode. ## Single command mode In single-command mode, 'lgraph_cypher' can be used to submit a single Cypher query and print the result directly to the terminal. The printed result can also be easily redirected to a specified file. This is handy when users need to get a lot of results from the server and save them in files. In this mode, the 'lgraph_cypher' tool has the following options: ### Command line Parameters: | Parameter | Type | Instructions | | --------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --help | \\ | List all parameters and descriptions. | | -example | \\ | List the command instances. | | -c | string | A database configuration file used to obtain ip and port information. | | -h | string | Database server IP address. Omit this parameter if you have a configuration file. The default value is' 127.0.0.1 ' | | -p | string | Database server port. Omit this parameter if you have a configuration file. The default value is 7071 | | -u | string | User name for logging in to the database. | | -P | string | Password for logging in to the database. | | -f | string | Contains the path to a single Cypher query single text file. | | -s | string | Single-line cypher query command. Start and end with `"`. | | -t | int | Specifies the server timeout threshold for cypher queries. The default value is 150 seconds. | | -format | string | Query result display mode. Supports two formats: 'plain' and 'table'. The 'plain' format prints the query results in a single column. The 'table' format displays the query results in a tabular format. The default value is' table ' | ### Examples: **cypher command file query:** ```powershell $ ./lgraph_cypher.py -c /home/usr/lgraph_standalone.json -u user -P password -f /home/usr/cypher.json ``` **cypher command single-sentence query:** ```powershell $ ./lgraph_cypher.py -c /home/usr/lgraph_standalone.json -u user -P password -s "MATCH (n) RETURN n" ``` ## Interactive mode 'lgraph_cypher' can also be run in interactive mode. In interactive mode, the client stays connected to the server and interacts with the user in read-evaluate-print-loop. ### Enter lgraph_cypher interaction mode: If no '-f' or '-s' command line option added, 'lgraph_cypher' will enter interactive mode when running. how to use it: ``` $ ./lgraph_cypher.py -c /home/usr/lgraph_standalone.json -u admin -P 73@TuGraph ``` If the login is successful, the corresponding login success message will be displayed: ``` ********************************************************************** * TuGraph Graph Database X.Y.Z * * * * Copyright(C) 2018 Ant Group. All rights reserved. * * * ********************************************************************** login success ---------------------------------- Host: 127.0.0.1 Port: 7071 Username: admin ---------------------------------- type ":help" to see all commands. > ``` Now we also provide an interactive shell for users to enter Cypher queries or use the ':help' command to check for available commands. ### Command Description In addition to the Cypher query, the shell of 'lgraph_cypher' accepts the following commands: | Command | Parameters | instructions | | ------------------------ | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | :help | \\ | Displays the server information and the corresponding description of all commands. | | :db_info | \\ | Query the current server status. /db/info for the corresponding REST API. | | :clear | \\ | Clear the screen. | | :use | {Graph Name} | The graph specified with this name defaults to `default` | | :source | `-t {Query the timeout value} -f {The query file}` | cypher command file query in interactive mode. The default timeout threshold is 150 seconds. Query file format reference No interactive query parameters. | | :exit | \\ | Exit interactive mode and return to the original command line. | | :format | `plain` or `table` | Change the display mode of cypher query results. Support 'plain' and 'table' modes. | | :save all/command/result | `-f {The file path}` `{Cypher}` | The cypher command (command), query result (result) or both (all) are stored. The default location is' /saved_cypher.txt ' | **Note:** - Each command should start with a colon `:`. **:save command example :** ``` :save all -f /home/usr/saved.txt match (n) where return n, n.name limit 1000 ``` ### cypher query command: In interactive mode, users can also directly input a single sentence cypher command for query, with "'; ` "end. Enter commands that are case insensitive. Here's an example: ``` login success >MATCH (n) RETURN n, n.name; +---+---+-------------+ | | n |n.name | +---+---+-------------+ | 0 | 0 |david | | 1 | 1 |Ann | | 2 | 2 |first movie | | 3 | 3 |Andres | +---+---+-------------+ time spent: 0.000520706176758 size of query: 4 > ``` `lgraph_cypher` supports multi-line input when typing commands. Users can use the `ENTER` key to type long query statements into multiple lines. In the case of multi-line input, the beginning of the command line will change from `>` to `=>`, and the user can continue to type the rest of the query. Example: ``` login success >MATCH (n) =>WHERE n.uid='M11' =>RETURN n, n.name; ``` ### Auxiliary Features: **Input History:** Press the up and down arrow keys in interactive mode to display the input history. **Auto Completion:** lgraph_cypher will automatically complete based on the input history. In the event of a completion prompt, pressing the right arrow key will automatically complete the command.