Bulk insert
Insert every row of a Data Table, or of a delimited text file read line by line, into a database table in batches, all or nothing.
Command in the Database toolkit · id ooa.database/bulk_insert · 12 inputs (1 required), 1 output
Inputs
| Input | Type | Required | Default | What it is |
|---|---|---|---|---|
| Table | String | Yes | Database table to insert into. | |
| Data | Table | No | Data Table whose rows are inserted (or use source_file). | |
| Columns | List | No | Database column for each Data Table or file column, in order; the Data Table's column names (or the file's header) when empty. | |
| Batch size | Number | No | 500 | Rows sent to the database per batch. |
| Session | String | No | db | Session name. |
| Source file | File | No | Delimited text file (CSV) whose rows are inserted instead of a Data Table; it is read as it goes, so large files fit. Empty fields are inserted as NULL. | |
| Delimiter | String | No | , | Field separator of the file: one character, or tab. |
| Start row | Number | No | 1 | Line of the file where reading starts (1 = the first line); lines above it, such as a title, are skipped. |
| Has header | Boolean | No | true | The first line read holds the column names, used as database columns when columns is empty. |
| Encoding | String | No | utf-8 | Text encoding of the file, e.g. utf-8 or windows-1252. |
| Column map | Dictionary | No | G2 (AA parity): source column (Data Table or file header) to database column; columns left out are not inserted. | |
| Timeout (seconds) | Number | No | 0 | G2 (AA parity): cancel a batch the database takes longer than this many seconds over; 0 waits as long as the step allows. |
Outputs
| Output | Type | What it is |
|---|---|---|
| rows_inserted | Number | Rows inserted. |