Insert Table
Inserts data into a SQLite database table.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Connection Id - The identifier of the database connection to use.
- Transaction Id - The identifier of the transaction to use (optional).
- Table Name - The name of the database table to insert data into.
- Table Data - The data to insert, provided as a table structure.
Options
- Replace - If true, uses "INSERT OR REPLACE" to replace existing rows with the same primary key. Default is false.
- Ignore Conflicts - If true, uses "INSERT OR IGNORE" to skip rows that would cause unique constraint violations. Default is false.
How It Works
The Insert Table node inserts data into a SQLite database table. When executed, the node:
- Validates the provided Connection Id and Table Name inputs
- Validates that Table Data exists
- Looks up the database connection in the SQLite connection pool
- If provided, looks up the transaction in the SQLite transaction store
- For each row in the Table Data:
- Clears previous command parameters
- For each column in the row:
- Constructs an INSERT command using the table name and column names
- Adds the column value as a parameter
- Executes the INSERT command
The node supports different conflict resolution strategies:
- Standard INSERT (default) - Fails on unique constraint violations
- INSERT OR REPLACE (when Replace is true) - Replaces existing rows with the same primary key
- INSERT OR IGNORE (when Ignore Conflicts is true) - Skips rows that would cause unique constraint violations
Requirements
- A valid database connection identifier from the Connect node
- An existing database table with matching column structure
- Valid table data with appropriate column names and values
- Sufficient database permissions for INSERT operations
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Connection Id
- Connection with the specified Id not found
- Empty or invalid Table Name
- Table Data does not exist or is invalid
- Database connection issues
- Constraint violations (unless handled by Replace or Ignore Conflicts options)
- Transaction with the specified Id not found (if Transaction Id is provided)
- Both Replace and Ignore Conflicts options selected simultaneously
Usage Notes
- The Table Data input should be a properly formatted table structure
- Column names in the Table Data should match the database table schema
- If a Transaction Id is provided, the insert operation will be part of that transaction
- Use the Replace option carefully as it will overwrite existing rows with the same primary key
- The Ignore Conflicts option is useful when inserting data that may have duplicates
- Only one of Replace or Ignore Conflicts should be selected at a time