Interactive console
The interactive console is Tarantool’s basic command-line interface for entering requests and seeing results. It is what users see when they start the server without an instance file. The interactive console is often called the Lua console to distinguish it from the administrative console, but in fact it can handle both Lua and SQL input.
The majority of examples in this manual show what users see with the interactive console. It includes:
tarantool>
prompt- instruction (a Lua request or an SQL statement)
- response (a display in either YAML or Lua format)
-- Interactive console example with Lua input and YAML output --
tarantool> box.info().replication
---
- 1:
id: 1
uuid: a5d22f66-2d28-4a35-b78f-5bf73baf6c8a
lsn: 0
...
The input language can be either Lua (default) or SQL. To change the input
language, run \set language <language>
, for example:
-- Set input language to SQL --
tarantool> \set language sql
---
- true
...
The delimiter can be changed to any character with \set delimiter <character>
.
By default, the delimiter is empty, which means the input does not need to end
with a delimiter.
For example, a common recommendation for SQL input is to use the semicolon delimiter:
-- Set ';' delimiter --
tarantool> \set delimiter ;
---
...
The output format can be either YAML (default) or Lua.
To change the output format, run \set output <format>
, for example:
-- Set output format Lua --
tarantool> \set output lua
true
The default YAML output format is the following:
- The output starts from a document-start line
"---"
. - Each item begins on a separate line starting with
"- "
. - Each sub-item in a nested structure is indented.
- The output ends with a document-end line
"..."
.
The alternative Lua format for console output is the following:
- There are no lines for document-start or document-end.
- Items are separated by commas.
- Each sub-item in a nested structure is placed inside “
{}
” braces.
So, when an input is a Lua object description, the output in the Lua format equals it.
For the Lua output format, you can specify an end of statement symbol.
It is added to the end of each output statement in the current session and
can be used for parsing the output by scripts. By default, the end of statement
symbol is empty. You can change it to any character or character sequence.
To set an end of statement symbol for the current session, run \`set output lua,local_eos=<symbol>`
,
for example:
-- Set output format Lua and '#' end of statement symbol --
tarantool> \set output lua,local_eos=#
true#
To switch back to the empty end of statement symbol:
-- Set output format Lua and empty end of statement symbol --
tarantool> \set output lua,local_eos=
true
The YAML output has better readability. The Lua output can be reused in requests. The table below shows output examples in these formats compared with the MsgPack format, which is good for database storage.
Type | Lua input | Lua output | YAML output | MsgPack storage |
---|---|---|---|---|
scalar | 1 |
1 |
--- - 1 ... |
\x01 |
scalar sequence | 1, 2, 3 |
1, 2, 3 |
--- - 1 - 2 - 3 ... |
\x01 \x02 \x03 |
2-element table | {1, 2} |
{1, 2} |
--- - - 1 - 2 ... |
0x92 0x01 0x02 |
map | {key = 1} |
{key = 1} |
--- - key: 1 ... |
\x81 \xa3 \x6b \x65 \x79 \x01 |
The console parameters of a Tarantool instance can also be changed from another instance using the console built-in module functions.
Since 2.10.0.
Keyboard shortcut | Effect |
---|---|
CTRL+C |
Discard current input with the SIGINT signal in the console mode and
jump to a new line with a default prompt. |
CTRL+D |
Quit Tarantool interactive console. |
Important
Keep in mind that CTRL+C
shortcut will shut Tarantool down if there is any currently running command
in the console.
The SIGINT signal stops the instance running in a daemon mode.