DATABASE Bulk insert rows function

Insert multiple rows into a table from a list of dictionaries with configurable batch size.

Help CentreBuilding Processes

This article describes the RPA Database functionality to bulk insert rows into a table.

For a full list of available functions, please read DATABASE functions.


Description

The Bulk insert rows function inserts multiple rows into a database table from a list of dictionaries. Each dictionary represents a row, with keys mapping to column names. Rows are inserted in configurable batches for performance.


Setting it up

To use the Bulk insert rows function, follow these instructions:

{{popups:rpas/add:action=db-bulk-insert}}

Once on a process map:

  1. Navigate to the process where you would like to add the Bulk insert rows function
  2. Click on the green button's drop-down (right side of the green button labelled "Process")
  3. On the menu that appears, click on the "+ Activity" item
  4. From here you can select the Bulk insert rows option
  5. Click "Add" once you are done

Input parameters

ParameterRequiredTypeDefaultDescription
NameYesText-The alias of a previously opened connection (from db-connect)
TableYesText-The target table name
RowsYesArray of dictionaries-The data to insert, where each dictionary represents a row with column names as keys
Batch sizeNoNumber1000The number of rows to insert per batch
VariableNoTextinserted_rowsVariable name to store the total number of inserted rows

Output variables

VariableTypeDescription
{inserted_rows}IntegerThe total number of rows successfully inserted

Errors

ErrorDescription
Connection not foundNo open connection exists with the specified name
Table not foundThe specified table does not exist in the database
Column mismatchThe dictionary keys do not match the table columns

Tips

  • Adjust batch_size to balance memory usage and performance – smaller batches use less memory, larger batches are faster
  • The keys in the first dictionary define the column mapping for all rows
  • Use db-list-columns to verify column names before inserting

Related functions

See it working on your own data

Everything documented here ships with the platform – try the document tools free, or go live in 7 days.