Skip to main content

Insert Into Database

Controlled node

Overview

The Insert Into Database node inserts new records into a specified table within a project database. It supports both single row inserts (as an object) and batch inserts (as an array of objects). The node validates the input data and returns the successfully inserted rows, including any auto-generated IDs or timestamps assigned by the database.

Inputs

InputTypeDescriptionDefault
RunEventTriggers the database insertion operation.-
Database IDDataThe unique identifier of the target database. Can be selected via the UI picker or provided as a string input.-
Table IDDataThe unique identifier of the target table within the selected database. Can be selected via the UI picker or provided as a string input.-
RowsDataThe data to insert. Accepts either a single dictionary/object representing one row, or an array of dictionaries/objects for batch insertion. Each object should contain key-value pairs matching the table's column names.-

Outputs

OutputTypeDescription
DoneEventFires when the insertion operation completes successfully or fails.
ResultDataContains an array of the inserted rows as they appear in the database (including any auto-generated fields like intellectible_id or timestamps). Returns an error object if the insertion fails.

Runtime Behavior and Defaults

When the Run event fires, the node performs the following operations:

  1. Input Validation: Validates that databaseId, tableId, and projectId are valid strings. If any validation fails, the node outputs an error object in the Result output.

  2. Data Normalization: The Rows input is normalized to an array of objects:

    • If a single object is provided, it is wrapped in an array
    • If an array is provided, it is used directly
    • Non-object values are filtered out
  3. Insertion: Calls projectDatabaseSystem.insertRowsAndColumns() to perform the actual database insertion. This creates new records with auto-generated intellectible_id values.

  4. Output: Returns the array of inserted rows through the Result output and fires the Done event.

Batch Insertion

For better performance when inserting multiple records, pass an array of objects to the Rows input rather than triggering the node multiple times with single objects.

Data Types

Ensure that the values in your row objects match the column types defined in the database schema. Type mismatches may cause the insertion to fail and return an error in the Result output.

Example Usage

Basic Single Row Insert

  1. Connect a Start node or button event to the Run input
  2. Use the UI pickers to select your Database and Table, or wire in string values from variables
  3. Connect a Dictionary node (or any data node outputting an object) to the Rows input with structure:
    {
    "name": "John Doe",
    "email": "john@example.com",
    "status": "active"
    }
  4. Connect the Done event to trigger subsequent workflow steps
  5. Access the inserted record (with its assigned intellectible_id) from the Result output

Batch Insert from CSV

  1. Use a Read CSV node to load data as an array of objects
  2. Connect the CSV output to the Rows input of Insert Into Database
  3. Select the target database and table via the UI or input connections
  4. Trigger the Run event to insert all rows in a single operation
  5. The Result output will contain an array of all inserted records with their assigned IDs