|
| 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