tt interactive console
The tt utility features a command-line console that allows executing
requests and Lua code interactively on the connected Tarantool
instances. It is similar to the
Tarantool interactive console with one key
difference: the tt console allows connecting to any available
instance, both local and remote. Additionally, it offers more flexible
output formatting capabilities.
To connect to a Tarantool instance using the tt console, run
tt connect.
Specify the instance URI and the user credentials in the corresponding options:
$ tt connect 192.168.10.10:3301 -u myuser -p p4$$w0rD• Connecting to the instance...• Connected to 192.168.10.10:3301192.168.10.10:3301>
If a user is not specified, the connection is established on behalf of
the guest user.
If the instance runs in the same tt environment, you can establish a
local connection with it by specifying the <application>:<instance>
string instead of the URI:
$ tt connect app:storage001• Connecting to the instance...• Connected to app:storage001app:storage001>
Local connections are established on behalf of the admin user.
To get the list of supported console commands, enter \help or ?. To
quit the console, enter \quit or \q.
Similarly to the Tarantool interactive console,
the tt console can handle Lua or SQL input. The default is Lua. For
Lua input, the tab-based autocompletion works automatically for loaded
modules.
To change the input language to SQL, run \set language sql:
app:storage001> \set language sqlapp:storage001> select * from bands where id = 1---- metadata:- name: idtype: unsigned- name: band_nametype: string- name: yeartype: unsignedrows:- [1, 'Roxette', 1986]...
To change the input language back to Lua, run \set language lua:
app:storage001> \set language luaapp:storage001> box.space.bands:select { 1 }---- - [1, 'Roxette', 1986]...
By default, the tt console prints the output data in the YAML format,
each tuple on the new line:
app:storage001> box.space.bands:select { }---- - [1, 'Roxette', 1986]- [2, 'Scorpions', 1965]- [3, 'Ace of Base', 1987]...
You can switch to alternative output formats – Lua or ASCII
(pseudographics) tables – using the \set output console command:
app:storage001> \set output luaapp:storage001> box.space.bands:select { }{{1, "Roxette", 1986}, {2, "Scorpions", 1965}, {3, "Ace of Base", 1987}};app:storage001> \set output tableapp:storage001> box.space.bands:select { }<table class="tableblock frame-all grid-all stretch"><colgroup><col style="width: 25%;"><col style="width: 50%;"><col style="width: 25%;"></colgroup><tbody><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IGlk)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IGJhbmRfbmFtZQ==)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IHllYXI=)}</p></td></tr><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IFJveGV0dGU=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE5ODY=)}</p></td></tr><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDI=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IFNjb3JwaW9ucw==)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE5NjU=)}</p></td></tr><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDM=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IEFjZSBvZiBCYXNl)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE5ODc=)}</p></td></tr></tbody></table>
The table output can be printed in the transposed format, where an object's fields are arranged in columns instead of rows:
app:storage001> \set output ttableapp:storage001> box.space.bands:select { }<table class="tableblock frame-all grid-all stretch"><colgroup><col style="width: 25%;"><col style="width: 25%;"><col style="width: 25%;"><col style="width: 25%;"></colgroup><tbody><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IGlk)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDI=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDM=)}</p></td></tr><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IGJhbmRfbmFtZQ==)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IFJveGV0dGU=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IFNjb3JwaW9ucw==)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IEFjZSBvZiBCYXNl)}</p></td></tr><tr><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IHllYXI=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE5ODY=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE5NjU=)}</p></td><td class="tableblock halign-left valign-top"><p class="tableblock">{decodeBase64(IDE5ODc=)}</p></td></tr></tbody></table>
For table and ttable output, more customizations are possible with
the following commands:
-
\set table_format– table format: default (pseudographics, or ASCII table), Markdown, or Jira-compatible format:app:storage001> \set table_format jiraapp:storage001> box.space.bands:select {}| id | 1 | 2 | 3 || band_name | Roxette | Scorpions | Ace of Base || year | 1986 | 1965 | 1987 | -
\set grahpics– enable or disable graphics for table cells in the default format:app:storage001> \set table_format defaultapp:storage001> \set graphics falseapp:storage001> box.space.bands:select {}id 1 2 3band_name Roxette Scorpions Ace of Baseyear 1986 1965 1987 -
\set table_column_width– maximum column width.app:storage001> \set table_column_width 6app:storage001> box.space.bands:select {}id 1 2 3band_n Roxett Scorpi Ace of+ame +e +ons + Baseyear 1986 1965 1987
Show help on the tt console.
Quit the tt console.
Show available keyboard shortcuts.
Set the input language. Possible values:
lua(default)sql
An analog of the tt connect option -l/--language.
Set the output format. Possible FORMAT values:
yaml(default) – each output item is a YAML object. Example:[1, 'Roxette', 1986]. Shorthand:\xy.lua– each output tuple is a separate Lua table. Example:{{1, "Roxette", 1986}};. Shorthand:\xl.table– the output is a table where tuples are rows. Shorthand:\xt.ttable– the output is a transposed table where tuples are columns. Shorthand:\xT.
The format of table and ttable output can be adjusted using the
\set table_format, \set graphics, and \set table_colum_width
commands.
An analog of the tt connect option -x/--outputformat.
Set the table format if the output format is table or ttable.
Possible values:
default– a pseudographics (ASCII) table.markdown– a table in the Markdown format.jira– a Jira-compatible table.
Whether to print pseudographics for table cells if the output format is
table or ttable. Possible values: true (default) and false.
The shorthands are:
\xGfortrue\xgforfalse
Set the maximum printed width of a table cell content. If the length
exceeds this value, it continues on the next line starting from the
+ (plus) sign.
Shorthand: \xw