# BulkImport

*BulkImport* efficiently copies a large number of rows into a PostgreSQL database table.

This function creates an Import object in its execution path. Use the [SetValue](https://docs.linx.software/reference/plugins/linx/content/setvalue) function to add the rows that you want to insert. See the [example](#example) below.

***

## Properties

### Connection string

The [connection string](https://docs.linx.software/reference/plugins/database/shared-properties/connectioneditor) that specifies how to connect to the database.

### Timeout

The timeout value in seconds. 0 indicates the bulk copy operation will wait indefinitely.

### Table

The name of the destination table.

Click on the **...** icon to open the Editor.

Destination Table Properties

**Connection string**

The [connection string](https://docs.linx.software/reference/plugins/database/shared-properties/connectioneditor) that specifies how to connect to the database.

**Table**

Select the relevant table to copy to.

**Columns**

Indicate which columns to copy to.

***

#### Batch size

The number of rows to collect in a transaction before it is committed to the server.

***

### Example

Suppose you have a CSV file with many records to load into a database table. Using the *BulkImport* function, as shown below, runs significantly faster than using the more generic [ExecuteSQL](https://docs.linx.software/reference/plugins/postgresql/content/executesql) function.

**Steps:**

1. From the PostgreSQL plugin, drag the BulkImport function onto the design canvas.
2. Set the BulkImport properties (see above for details).
3. From the File plugin, drag the TextFileRead function onto the design canvas (nested below your BulkImport function).
4. Set the *TextFileRead* properties to read each row from the source file for the destination database, defining the fields to assist with target mapping.
5. Drag the *SetValue* function from the Linx plugin onto the design canvas, nested below the TextFileRead function.

   <div align="left"><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-793622eaee3e8576c84e76ea4d74ea4160981d29%2Fbulkimportprocess.png?alt=media" alt="Bulk Import Example"></div>
6. Set the *Target* property of the SetValue function to `BulkImport.Import.Write`.

<div align="left"><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-1c0a44ff1b8cafe221178f6de24bc2534132de4c%2Fbulkimport.png?alt=media" alt="Bulk Import Example"></div>

7. Then click the **Set Fields editor** button next to the *Source* property to assign the values to the table's columns.

   <div align="left"><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-bad0bd4f4f4df7d3821d135cdfe01c73856419b1%2Fbulkimportsetfields.png?alt=media" alt="Bulk Import Example"></div>
