Database Upsert
Database Upsert writes the incoming JSON as rows into a table in an
external database. A row whose values in the keyColumns match an
existing row updates that row in place; the rest are inserted. You find
it on the node picker’s Storage shelf.
The node connects with a secret of type Database credentials. Create one under Connections → Secrets first; see Secrets.
Configuration
Section titled “Configuration”

| Field | Type | Default | Description |
|---|---|---|---|
Secret credential (secretCredentialId) | string ✦ (required) | — | The database credentials to connect with, chosen from your secrets. |
Extra credentials (extraCredentials) | key-value map (optional) | — | Extra connection settings merged on top of the chosen secret’s config. |
Table (table) | string ✦ (required) | — | The table to upsert the incoming rows into. |
Key columns (keyColumns) | key-value map (optional) | — | The column(s) used to detect an existing row to update instead of inserting. |
Fields marked ✦ accept expressions.
Try this node — run it once against your own workspace, with your credentials, without building a flow first.
keyColumns is required and must name columns that form a unique or
primary key constraint on the table; the run fails when it is empty.
When a conflict is found on those columns, all other columns of the
table are updated from the incoming row.
extraCredentials entries are merged into the connection config as
written and are not expression-resolved. To choose the credentials at
runtime, switch the credentials field to expression mode and resolve the
id of a credential secret from flow data.
Column mapping
Section titled “Column mapping”The incoming JSON keys map to column names exactly as in
Database Insert: extra keys are ignored,
missing nullable columns become NULL, columns with a database default
are left to the database, and a missing non-nullable column without a
default fails the run. Place a Mapper or
Transformer upstream when the shape does not
match the table.
Output
Section titled “Output”The node emits the rows it wrote, after column mapping, as a JSON array.
An Agent can call this node as a tool. It writes to an outside system, so agent calls are approval-gated in every mode below Autopilot; see Add human approval.
Example
Section titled “Example”The Database / Upsert template in the
template gallery upserts a customer into
smoke_customers with Key columns set to id. Running it twice
leaves one row: the second run finds the same id and updates the
other columns instead of inserting a duplicate. Its upstream Injector
builds the row with an expression:
{"id":"ups-1","name":{!! json_encode($start->name) !!},"email":"ups@example.com"}json_encode() quotes the name and escapes anything inside it, and the raw
tags {!! !!} keep the result as it is. {{ }} would HTML-escape it, so a
name such as O'Brien & Sons would be stored as O'Brien & Sons.
The same pattern syncs API results without duplicating rows: point the
key columns at the source system’s identifier (for example
external_id) and feed the node from a
REST Request.
Related
Section titled “Related”- Database Insert always inserts and fails on a duplicate key.
- Database Select reads from an external database.
- Table Store Upsert is the same write against a built-in table store.
- Use an external database walks through the credential setup.