|
| 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 | + You should have :ref:`read access <authentication-owners_privileges>` to the required space to be able to export data. |
| 28 | + |
| 29 | +.. NOTE:: |
| 30 | + |
| 31 | + Exporting isn't supported for the :ref:`interval <index-box_interval>` field type. |
| 32 | + |
| 33 | + |
| 34 | +.. _tt-export-default: |
| 35 | + |
| 36 | +Exporting with default settings |
| 37 | +------------------------------- |
| 38 | + |
| 39 | +The command below exports data of the ``customers`` space to the ``customers.csv`` file: |
| 40 | + |
| 41 | +.. code-block:: console |
| 42 | +
|
| 43 | + $ tt crud export localhost:3301 customers.csv customers |
| 44 | +
|
| 45 | +If the ``customers`` space has five fields (``id``, ``bucket_id``, ``firstname``, ``lastname``, and ``age``), the file with exported data might look like this: |
| 46 | + |
| 47 | +.. code-block:: text |
| 48 | +
|
| 49 | + 1,477,Andrew,Fuller,38 |
| 50 | + 2,401,Michael,Suyama,46 |
| 51 | + 3,2804,Robert,King,33 |
| 52 | + # ... |
| 53 | +
|
| 54 | +If a tuple contains a ``null`` value, for example, ``[1, 477, 'Andrew', null, 38]``, it is exported as an empty value: |
| 55 | + |
| 56 | +.. code-block:: text |
| 57 | +
|
| 58 | + 1,477,Andrew,,38 |
| 59 | +
|
| 60 | +
|
| 61 | +.. _tt-export-header: |
| 62 | + |
| 63 | +Exporting headers |
| 64 | +----------------- |
| 65 | + |
| 66 | +To export data with a space's field names in the first row, use the ``--header`` option: |
| 67 | + |
| 68 | +.. code-block:: console |
| 69 | +
|
| 70 | + $ tt crud export localhost:3301 customers.csv customers \ |
| 71 | + --header |
| 72 | +
|
| 73 | +In this case, field values start from the second row, for example: |
| 74 | + |
| 75 | +.. code-block:: text |
| 76 | +
|
| 77 | + id,bucket_id,firstname,lastname,age |
| 78 | + 1,477,Andrew,Fuller,38 |
| 79 | + 2,401,Michael,Suyama,46 |
| 80 | + 3,2804,Robert,King,33 |
| 81 | + # ... |
| 82 | +
|
| 83 | +
|
| 84 | +.. _tt-export-compound-data: |
| 85 | + |
| 86 | +Exporting compound data |
| 87 | +----------------------- |
| 88 | + |
| 89 | +By default, ``tt`` exports empty values for fields containing compound data like arrays or maps. |
| 90 | +To export compound values in a specific format, use the ``--compound-value-format`` option. |
| 91 | +For example, the command below exports compound values serialized in JSON: |
| 92 | + |
| 93 | +.. code-block:: console |
| 94 | +
|
| 95 | + $ tt crud export localhost:3301 customers.csv customers \ |
| 96 | + --compound-value-format json |
| 97 | +
|
| 98 | +
|
| 99 | +.. _tt-export-options: |
| 100 | + |
| 101 | +Options |
| 102 | +------- |
| 103 | + |
| 104 | +.. option:: --batch-queue-size INT |
| 105 | + |
| 106 | + Specify the maximum number of tuple batches in a queue between a fetch and write threads (the default is ``32``). |
| 107 | + |
| 108 | + ``tt`` exports data using two threads: |
| 109 | + |
| 110 | + * A *fetch* thread makes requests and receives data from a Tarantool instance. |
| 111 | + * A *write* thread encodes received data and writes it to the output. |
| 112 | + |
| 113 | + The fetch thread uses a queue to pass received tuple batches to the write thread. |
| 114 | + If a queue is full, the fetch thread waits until the write thread takes a batch from the queue. |
| 115 | + |
| 116 | +.. option:: --batch-size INT |
| 117 | + |
| 118 | + Specify the number of tuples to transfer per request (the default is ``10000``). |
| 119 | + |
| 120 | +.. option:: --compound-value-format STRING |
| 121 | + |
| 122 | + Set a format used to export compound values like arrays or maps. |
| 123 | + By default, ``tt`` exports empty values for fields containing such values. |
| 124 | + |
| 125 | + Supported formats: ``json``. |
| 126 | + |
| 127 | + See also: :ref:`Exporting compound data <tt-export-compound-data>`. |
| 128 | + |
| 129 | +.. option:: --header |
| 130 | + |
| 131 | + Specify whether to add field names in the first row. |
| 132 | + |
| 133 | + See also: :ref:`Exporting headers <tt-export-header>`. |
| 134 | + |
| 135 | +.. option:: --password STRING |
| 136 | + |
| 137 | + Specify a password used to connect to the instance. |
| 138 | + |
| 139 | +.. option:: --readview |
| 140 | + |
| 141 | + Specify whether to export data using a `read view <https://www.tarantool.io/en/enterprise_doc/read_views/>`_. |
| 142 | + |
| 143 | +.. option:: --username STRING |
| 144 | + |
| 145 | + Specify a username for connecting to the instance. |
0 commit comments