Skip to content

Commit 5c9b5e2

Browse files
Document tt export/import (#3737)
1 parent 6233db8 commit 5c9b5e2

File tree

7 files changed

+472
-1
lines changed

7 files changed

+472
-1
lines changed

conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
extlinks = {
4242
'tarantool-issue': ('https://github.com/tarantool/tarantool/issues/%s', 'gh-'),
4343
'tarantool-release': ('https://github.com/tarantool/tarantool/releases/%s', 'v. '),
44+
'tt-release': ('https://github.com/tarantool/tt/releases/v%s', 'v. '),
4445
'doc-issue': ('https://github.com/tarantool/doc/issues/%s', 'doc-'),
4546
'tarantool-sec-issue': ('https://github.com/tarantool/security/issues/%s', 'ghs-'),
4647
}
@@ -59,7 +60,7 @@
5960
project = u'Tarantool'
6061

6162
# |release| The full version, including alpha/beta/rc tags.
62-
release = "2.11.0"
63+
release = "2.11.1"
6364
# |version| The short X.Y version.
6465
version = '.'.join(release.split('.')[0:2])
6566

doc/reference/tooling/tt_cli/commands.rst

+9
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ help for the given command.
3434
- Manipulate Tarantool core dumps
3535
* - :doc:`create <create>`
3636
- Create an application from a template
37+
* - :doc:`crud <crud>`
38+
- Interact with the CRUD module (`Enterprise only <https://www.tarantool.io/compare/>`_)
39+
* - :doc:`export <export>`
40+
- Export data to a file (`Enterprise only <https://www.tarantool.io/compare/>`_)
3741
* - :doc:`help <help>`
3842
- Display help for ``tt`` or a specific command
43+
* - :doc:`import <import>`
44+
- Import data from a file (`Enterprise only <https://www.tarantool.io/compare/>`_)
3945
* - :doc:`init <init>`
4046
- Create a new ``tt`` environment in the current directory
4147
* - :doc:`install <install>`
@@ -81,7 +87,10 @@ help for the given command.
8187
connect <connect>
8288
coredump <coredump>
8389
create <create>
90+
crud <crud>
91+
export <export>
8492
help <help>
93+
import <import>
8594
init <init>
8695
install <install>
8796
instances <instances>

doc/reference/tooling/tt_cli/crud.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _tt-crud:
2+
3+
Interacting with the CRUD module
4+
================================
5+
6+
.. admonition:: Enterprise Edition
7+
:class: fact
8+
9+
This command is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
10+
11+
.. code-block:: console
12+
13+
$ tt crud COMMAND [COMMAND_OPTION ...]
14+
15+
``tt crud`` enables the interaction with a cluster using the `CRUD <https://github.com/tarantool/crud>`_ module.
16+
``COMMAND`` is one of the following:
17+
18+
* ``export``: export a cluster's data to a file. Learn more at :ref:`Exporting data <tt-export>`.
19+
* ``import``: import data from a file. Learn more at :ref:`Importing data <tt-import>`.
+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
.. _tt-export:
2+
3+
Exporting data
4+
==============
5+
6+
.. admonition:: Enterprise Edition
7+
:class: fact
8+
9+
This command is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
10+
11+
12+
.. code-block:: console
13+
14+
$ tt [crud] export URI FILE SPACE [EXPORT_OPTION ...]
15+
16+
``tt [crud] export`` exports a space's data to a file.
17+
The ``crud`` command is optional and can be used to export a cluster's data by using the `CRUD <https://github.com/tarantool/crud>`_ module. Without ``crud``, data is exported using the :ref:`box.space <box_space>` API.
18+
19+
``tt [crud] export`` takes the following arguments:
20+
21+
* ``URI``: The URI of a router instance if ``crud`` is used. Otherwise, it should specify the URI of a storage.
22+
* ``FILE``: The name of a file for storing exported data.
23+
* ``SPACE``: The name of a space from which data is exported.
24+
25+
.. NOTE::
26+
27+
:ref:`Read access <authentication-owners_privileges>` to the space is required to export its data.
28+
29+
.. _tt-export-limitations:
30+
31+
Limitations
32+
-----------
33+
34+
Exporting isn't supported for the :ref:`interval <index-box_interval>` field type.
35+
36+
37+
.. _tt-export-default:
38+
39+
Exporting with default settings
40+
-------------------------------
41+
42+
The command below exports data of the ``customers`` space to the ``customers.csv`` file:
43+
44+
.. code-block:: console
45+
46+
$ tt crud export localhost:3301 customers.csv customers
47+
48+
If the ``customers`` space has five fields (``id``, ``bucket_id``, ``firstname``, ``lastname``, and ``age``), the file with exported data might look like this:
49+
50+
.. code-block:: text
51+
52+
1,477,Andrew,Fuller,38
53+
2,401,Michael,Suyama,46
54+
3,2804,Robert,King,33
55+
# ...
56+
57+
If a tuple contains a ``null`` value, for example, ``[1, 477, 'Andrew', null, 38]``, it is exported as an empty value:
58+
59+
.. code-block:: text
60+
61+
1,477,Andrew,,38
62+
63+
64+
.. _tt-export-header:
65+
66+
Exporting headers
67+
-----------------
68+
69+
To export data with a space's field names in the first row, use the ``--header`` option:
70+
71+
.. code-block:: console
72+
73+
$ tt crud export localhost:3301 customers.csv customers \
74+
--header
75+
76+
In this case, field values start from the second row, for example:
77+
78+
.. code-block:: text
79+
80+
id,bucket_id,firstname,lastname,age
81+
1,477,Andrew,Fuller,38
82+
2,401,Michael,Suyama,46
83+
3,2804,Robert,King,33
84+
# ...
85+
86+
87+
.. _tt-export-compound-data:
88+
89+
Exporting compound data
90+
-----------------------
91+
92+
By default, ``tt`` exports empty values for fields containing compound data such as arrays or maps.
93+
To export compound values in a specific format, use the ``--compound-value-format`` option.
94+
For example, the command below exports compound values serialized in JSON:
95+
96+
.. code-block:: console
97+
98+
$ tt crud export localhost:3301 customers.csv customers \
99+
--compound-value-format json
100+
101+
102+
.. _tt-export-options:
103+
104+
Options
105+
-------
106+
107+
.. option:: --batch-queue-size INT
108+
109+
The maximum number of tuple batches in a queue between a fetch and write threads (the default is ``32``).
110+
111+
``tt`` exports data using two threads:
112+
113+
* A *fetch* thread makes requests and receives data from a Tarantool instance.
114+
* A *write* thread encodes received data and writes it to the output.
115+
116+
The fetch thread uses a queue to pass received tuple batches to the write thread.
117+
If a queue is full, the fetch thread waits until the write thread takes a batch from the queue.
118+
119+
.. option:: --batch-size INT
120+
121+
The number of tuples to transfer per request (the default is ``10000``).
122+
123+
.. option:: --compound-value-format STRING
124+
125+
A format used to export compound values like arrays or maps.
126+
By default, ``tt`` exports empty values for fields containing such values.
127+
128+
Supported formats: ``json``.
129+
130+
See also: :ref:`Exporting compound data <tt-export-compound-data>`.
131+
132+
.. option:: --header
133+
134+
Add field names in the first row.
135+
136+
See also: :ref:`Exporting headers <tt-export-header>`.
137+
138+
.. option:: --password STRING
139+
140+
A password used to connect to the instance.
141+
142+
.. option:: --readview
143+
144+
Export data using a `read view <https://www.tarantool.io/en/enterprise_doc/read_views/>`_.
145+
146+
.. option:: --username STRING
147+
148+
A username for connecting to the instance.

0 commit comments

Comments
 (0)