# Import Data

SQLife imports tabular files into a selected database table. The importer supports Excel and delimited text files, with a preview and editable column mapping.

## Open the Importer

1. Connect to a database.
2. Open **Database -> Import Data**, or use the import action from a table when available.
3. Choose the source file with the file button.

The preview table is populated from the selected file. For Excel files, select the worksheet when more than one sheet is available.

## Select the Target

Use the searchable **Schema** and **Table** selectors. The mapping table then shows:

- source field name and type;
- target column name and type;
- the conversion setting used for the mapping.

Edit mapping cells as needed. Mapping configurations can be saved with the save button and selected again later. Use the delete button to remove a saved mapping.

## File and Header Settings

- **Header**: treat the first selected row as column headers.
- **Header line**: choose which source row is used as the header.
- **Sheet**: select the Excel worksheet.
- **Delimiter** and **quote**: configure delimited text parsing.

Use a consistent encoding and delimiter in the source file. Preview the file before starting an import.

## Import Options

- **Ignore errors**: continue processing when individual rows fail. Review the database errors after the operation.
- **Support LOB**: enable import of large text and binary values.
- **Unescape line break**: convert escaped line breaks in text values.
- **With header**: include a header row when interpreting the source.
- **Truncate**: remove existing target rows before importing. Treat this as destructive.
- **Multi-threads** and **thread count**: use parallel import for suitable independent data sets.
- **Commit batch**: commit after the configured number of rows.

Parallel import can change execution order and increase database load. Do not use it when rows depend on one another or when the target database requires strict ordering.

## Run the Import

1. Confirm the preview, schema, table, worksheet, and mappings.
2. Check the import options.
3. Click **Import**.
4. Monitor the progress and database messages.

Import behavior is database-dependent. A failed row may leave earlier committed batches in the database, so use a transaction/backup strategy appropriate for the data.

## Common Problems

- **No preview**: check the file path, worksheet, header line, delimiter, and quote character.
- **Empty mapping**: select the target schema and table, then choose or edit the mapping.
- **Type errors**: correct the source values or the conversion mapping.
- **Constraint errors**: verify keys, required columns, and parent rows before retrying.
- **Unexpected existing data removed**: confirm that **Truncate** was not enabled.

For repeat imports, save a mapping and reuse it only after checking that the source column order and types have not changed.
