Command Line Interface (CLI)
Kùzu provides a CLI shell through which you can issue Cypher queries or CALL
commands to query
metadata. See the installation docs for instructions on how
to install the CLI and the quick start page for its basic usage.
Start the shell
Kùzu supports on-disk, as well as in-memory databases. The functionality of the CLI is identical for both on-disk and in-memory modes.
On-disk database
You can create an on-disk database in the CLI by specifying a path after
the kuzu
command in the terminal. This opens the database on-disk, in read-write mode, and the
data is persisted to disk after the CLI shell is closed. Note that if the database
directory does not exist, it will be created for you.
In-memory database
Alternatively, you can create an in-memory database by omitting the path entirely, and just calling kuzu
from your terminal:
Shell commands
Once you start the shell, you can issue Cypher queries as shown in the get started
section. List all available shell commands by running ./kuzu -h
.
To limit the buffer pool size to use just 4GB of memory, you can use the following command:
:help
Show built-in command list within the Kùzu shell.
:clear
Clear shell. Alternatively, you can use Ctrl + L
to clear the shell.
:quit
Exit from shell. Alternatively, you can use Ctrl + D
to exit the shell.
:max_rows [max_rows]
Set maximum number of rows for display. 0 defaults to 20.
:max_width [max_width]
Set maximum width in characters for display. Defaults to terminal width if unable to display first and last columns.
:mode [mode]
Set output mode. The default mode is box
. See the output modes section below for more details.
:stats [on|off]
Toggle query statistics on or off. The default is on
. Query statistics include the number of tuples, columns, and execution time.
:multiline
Set multiline editing mode. This is the default editing mode. In multiline editing mode, you can write queries that span multiple lines. In this mode, you are able to go back to previous lines and edit them. Comments and newlines will stay when saved into history when using this mode.
The ‣
symbol indicates the current line.
:singleline
Set singleline editing mode. In singleline editing mode, you can only write queries on a single line. If your query spans multiple lines, you will not be able to go back to previous lines and edit them. Single-line comments and newlines will not be saved into history when using this mode.
:highlight [on|off]
Toggle syntax highlighting on or off. The default is on
. When enabled, the shell will highlight Cypher keywords,
constants and literals, syntax errors, and comments. Error highlighting and multiline comment highlighting are not available in singleline mode.
:render_errors [on|off]
Toggle error highlighting on or off. The default is on
. When enabled, the shell will highlight syntax errors in red. In particular,
mismatched brackets and unclosed quotes will be highlighted. Error highlighting is not available in singleline mode.
Interrupt shell
To interrupt a running query, use Ctrl + C
in CLI. Note: We currently don’t support interrupting a running COPY
statement.
Non-interactive usage
You can also read and process a file in non-interactive mode via the CLI. Consider that you have the following DDL file:
Pipe the file content to the CLI as follows:
Query progress
For queries that might take a significant amount of time to execute, a progress bar can be enabled that displays the number of pipelines that have been executed (each query is broken down into one or more pipelines), as well as the percentage of the data processed in a pipeline. This gives an estimate for how much of a pipeline has executed.
The progress bar is not enabled by default. To enable the progress bar, use the following command:
To further configure the progress bar, see the configuration section.
Output modes
The :mode [mode]
command allows you to change the appearance of the tables returned by queries.
To view the available modes, use the :mode
command without any arguments:
To change the output mode, use the :mode
command followed by the desired mode:
The :max_rows
and :max_width
commands can be used to control the number of rows and the width
of the box
, column
, table
, and markdown
output modes.
Multi-line Cypher statements
The CLI supports queries written in multiple lines. If a semicolon is omitted, hitting enter will allow users to continue the query in a newline instead of executing it.