> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tablepro.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Import & Export

> Export to CSV, JSON, SQL, MQL, or XLSX. Import SQL, JSON, and CSV files with column mapping, transaction safety, and progress tracking.

# Import & Export

Export data in five formats (CSV, JSON, SQL, MQL, XLSX), import SQL, JSON, and CSV files (with gzip support for SQL), and paste tabular data from the clipboard into the grid.

## Export Data

1. Run a query or open a table
2. Click **Export** in the toolbar (`Cmd+Shift+E`)
3. Choose a format, select tables, configure options
4. Click **Export**

TablePro remembers the last format and options you exported with, so the dialog opens ready for a repeat export. Option changes stick only after a successful export; cancelling the dialog discards them. **Reset to Defaults** under the options restores the stock settings for the current format.

<Note>
  **MongoDB**: SQL export is not available. Use CSV, JSON, MQL, or XLSX. MQL generates `db.collection.insertMany([...])` scripts for `mongosh`.
</Note>

<Note>
  **Redis**: SQL and MQL exports are not available. Use CSV, JSON, or XLSX.
</Note>

<Frame caption="Export dialog">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-dialog.png" alt="Export dialog" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-dialog-dark.png" alt="Export dialog" />
</Frame>

### Export Formats

<Tabs>
  <Tab title="CSV">
    | Option                                    | Default   |
    | ----------------------------------------- | --------- |
    | Header row                                | Yes       |
    | Delimiter (comma, semicolon, tab, pipe)   | Comma     |
    | Quote handling (always, as needed, never) | As needed |
    | NULL to empty strings                     | Yes       |
    | Line breaks in values to spaces           | No        |
    | Line ending (LF, CRLF, CR)                | LF        |
    | Decimal separator (period, comma)         | Period    |
    | Formula sanitization                      | Yes       |

    <Frame caption="CSV export options">
      <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-csv-options.png" alt="CSV export options" />

      <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-csv-options-dark.png" alt="CSV export options" />
    </Frame>
  </Tab>

  <Tab title="JSON">
    Exports as an array of objects.

    | Option                         | Default |
    | ------------------------------ | ------- |
    | Pretty print                   | Yes     |
    | Include NULL values            | Yes     |
    | Preserve all values as strings | No      |

    <Frame caption="JSON export options">
      <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-json-options.png" alt="JSON export options" />

      <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-json-options-dark.png" alt="JSON export options" />
    </Frame>
  </Tab>

  <Tab title="SQL">
    Global options:

    | Option                         | Default |
    | ------------------------------ | ------- |
    | Compress with gzip (`.sql.gz`) | No      |
    | Batch size (rows per INSERT)   | 500     |

    Per-table options (configurable individually for multi-table exports):

    | Option                       | Default |
    | ---------------------------- | ------- |
    | Include CREATE TABLE         | Yes     |
    | Include DROP TABLE IF EXISTS | Yes     |
    | Include INSERT data          | Yes     |

    <Frame caption="SQL export options">
      <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-sql-options.png" alt="SQL export options" />

      <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-sql-options-dark.png" alt="SQL export options" />
    </Frame>
  </Tab>

  <Tab title="MQL">
    MongoDB only. Generates `insertMany()` scripts that run directly in `mongosh`.

    | Option                                  | Default |
    | --------------------------------------- | ------- |
    | Batch size (documents per `insertMany`) | 500     |

    Output is a `.js` file:

    ```javascript theme={null}
    db.users.insertMany([
      {"_id": {"$oid": "507f1f77bcf86cd799439011"}, "name": "Alice", "age": 30},
      {"_id": {"$oid": "507f1f77bcf86cd799439012"}, "name": "Bob", "age": 25}
    ]);
    ```
  </Tab>

  <Tab title="XLSX">
    | Option                           | Default |
    | -------------------------------- | ------- |
    | Include headers (bold first row) | Yes     |
    | NULL as empty cells              | Yes     |

    Each table exports as a separate worksheet. Numbers are stored as numeric cells for proper Excel formatting. Tables exceeding 1,048,576 rows (Excel's limit) auto-split into multiple sheets.

    <Frame caption="Excel export options">
      <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-xlsx-options.png" alt="Excel export options" />

      <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/export-xlsx-options-dark.png" alt="Excel export options" />
    </Frame>
  </Tab>
</Tabs>

### Exporting Query Results

Right-click the results grid and select **Export Results...**, or go to **File** > **Export Results...**. Choose a format, configure options, and click **Export**. Only in-memory results are exported.

<Tip>
  Use LIMIT in your query to control export size for large tables.
</Tip>

### Exporting Entire Tables

Click a table in the sidebar and click **Export**, or run `SELECT * FROM table_name` and export.

<Tip>
  Export multiple tables at once via the export dialog's tree view. SQL exports support per-table options for structure, DROP, and data.
</Tip>

### Streaming Export

Table exports stream rows directly from the database to disk (shipped v0.33.0). No in-memory buffering, no row-count limit: tables larger than RAM export fine.

Properties:

* Streamed write per row, constant memory regardless of table size
* Atomic file write: the destination file appears only on success, partial files are removed on failure
* Cancellable from the progress dialog. Cancellation removes the partial file
* Per-row error handling, configurable in the export dialog:

| Mode                  | Behavior                                                                             |
| --------------------- | ------------------------------------------------------------------------------------ |
| **Stop and Rollback** | Stop on first row error and discard the output file.                                 |
| **Stop and Commit**   | Stop on first row error but keep rows already written.                               |
| **Skip and Continue** | Skip the failing row, log it, and continue. A summary lists skipped rows at the end. |

Streaming applies to whole-table exports. Result-grid exports use in-memory data.

## Clipboard Paste (CSV/TSV)

Paste tabular data directly into the data grid. Press `Cmd+V` after selecting a row. Format is auto-detected: tabs parse as TSV, commas as CSV.

## Import Data

Import `.sql` and `.sql.gz` files (statements execute directly against your database: backups, migrations, seed data), `.json` / `.jsonl` files into a table (see [Import JSON Data](#import-json-data)), or `.csv` / `.tsv` files into a table (see [Import CSV Data](#import-csv-data)).

<Note>
  **MongoDB**: SQL import is not available. Use `mongoimport` or the MQL shell.
</Note>

### Import Workflow

<Steps>
  <Step title="Open Import Dialog">
    Click **File** > **Import** > **From SQL** (`Cmd+Shift+I`), or drag and drop a `.sql` / `.sql.gz` file onto the app.
  </Step>

  <Step title="Configure Options">
    Set encoding, transaction wrapping, and foreign key check options. TablePro remembers the encoding and options from your last successful import; **Reset to Defaults** next to the Options header restores them.
  </Step>

  <Step title="Preview and Import">
    Review the SQL preview, statement count, and file size. Click **Import** to execute.
  </Step>
</Steps>

<Frame caption="Import dialog with SQL file preview">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/import-dialog.png" alt="Import dialog" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/import-dialog-dark.png" alt="Import dialog" />
</Frame>

### Import Options

| Option                     | Description                                        | Default           |
| -------------------------- | -------------------------------------------------- | ----------------- |
| On error                   | How to handle failed statements (see below)        | Stop and Rollback |
| Encoding                   | File encoding: UTF-8, UTF-16, Latin1, or ASCII     | UTF-8             |
| Wrap in transaction        | Execute all statements within a single transaction | Yes               |
| Disable foreign key checks | Temporarily disable FK constraints during import   | Yes               |

For PostgreSQL the checkbox runs `SET session_replication_role = replica`, which requires the `REPLICATION` role or superuser. Most managed Postgres providers (RDS, Neon, Supabase) reject it, so the checkbox may have no effect there. TablePro's SQL exports already emit foreign key constraints with `ALTER TABLE ... ADD CONSTRAINT` after data load, so the dump round-trips without needing the privilege.

For MySQL the checkbox runs `SET FOREIGN_KEY_CHECKS = 0` and is supported on standard accounts. SQLite uses `PRAGMA foreign_keys = OFF`. Drivers without an equivalent (most NoSQL drivers) ignore the option.

### Error Handling Modes

Three modes for handling errors during import:

| Mode                  | Behavior                                                                                                                                   |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| **Stop and Rollback** | Stops on first error. If transaction is enabled, rolls back all changes. Default.                                                          |
| **Stop and Commit**   | Stops on first error. Commits statements that succeeded before the error.                                                                  |
| **Skip and Continue** | Logs failed statements and continues importing. Shows a summary with all errors at the end. Transaction wrapping is disabled in this mode. |

In **Skip and Continue** mode, failed statements are collected (up to 1,000) with line numbers and error messages. After import completes, a summary dialog shows how many succeeded vs failed, with a scrollable error list and a "Copy Errors to Clipboard" button.

### Import JSON Data

Choose **File** > **Import** > **From JSON** and pick a `.json`, `.jsonl`, or `.ndjson` file, and TablePro opens a dedicated JSON import sheet. It accepts an array of objects `[{...}, {...}]`, newline-delimited JSON (one object per line, streamed for large files), and TablePro's own JSON export shape `{ "table": [ {...} ] }`, so an export round-trips back in.

Choose a destination:

* **Existing table**: pick the table, then map each JSON field to a column. Fields are auto-matched by name; toggle any field off to skip it, or remap it to a different column. Columns with no matching field keep their default or NULL.
* **New table**: name the table and review the columns TablePro infers from the data. Each column's name, type, primary key, nullable flag, and default are editable before the table is created.

Rows insert through parameterized statements, so JSON values are never concatenated into SQL. Nested objects and arrays are stored as JSON text. The on-error, transaction, and "delete existing rows" options work the same as SQL import.

### Import CSV Data

Choose **File** > **Import** > **From CSV** and pick a `.csv` or `.tsv` file. TablePro opens the same row import sheet used for JSON, with CSV-specific parsing options. The delimiter, quote character, encoding, and line ending are auto-detected; change any of them and the field mapping re-reads the file.

Choose a destination:

* **Existing table**: pick the table, then map each CSV column to a table column. Columns are auto-matched by header name; toggle one off to skip it, or remap it.
* **New table**: name the table and review the columns TablePro infers from the data. Each column's name, type, primary key, nullable flag, and default are editable before the table is created.

CSV parsing options:

| Option                           | Description                                              | Default            |
| -------------------------------- | -------------------------------------------------------- | ------------------ |
| Delimiter                        | Comma, semicolon, tab, or pipe                           | Auto-detect        |
| Quote character                  | Double or single quote                                   | Double quote (`"`) |
| Encoding                         | UTF-8, ISO Latin 1, or Windows-1252                      | Auto-detect        |
| First row is a header            | Use row 1 as column names; off imports every row as data | Yes                |
| Trim leading and trailing spaces | Trim each field before import                            | No                 |
| Treat empty values as NULL       | Insert NULL for empty fields instead of empty text       | Yes                |
| NULL text                        | An extra value imported as NULL, for example `\N`        | None               |

Quoted fields keep embedded commas and newlines (RFC 4180), and doubled quotes (`""`) decode to a single quote. Rows insert through parameterized statements in batches. The on-error, transaction, and "delete existing rows" options work the same as SQL import.

## Progress and Errors

During import, a progress bar shows statements processed and overall completion.

<Frame caption="Import progress">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/import-progress.png" alt="Import progress" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/import-progress-dark.png" alt="Import progress" />
</Frame>
