Skip to main content

SQL Insert

Inserts a row into an SQL database for each message, and leaves the message content unchanged.

FieldTypeDefaultDescription
DriverstringDatabase driver (required)
DSNstringConnection string for the target database (required)
TablestringThe target table (required)
ColumnsarrayColumn names to populate (required)
Args MappingBloblangMaps message fields to column values. Must evaluate to an array matching the number of columns (required)
PrefixstringAn optional prefix to prepend before INSERT
SuffixstringAn optional suffix to append (e.g., ON CONFLICT (name) DO NOTHING)
Init StatementstringSQL statement to execute on the first connection
Conn Max Idle TimestringMaximum idle duration before a connection is closed
Conn Max Life TimestringMaximum total lifetime of a connection
Conn Max Idleinteger2Maximum number of idle connections in the pool
Conn Max Openinteger0Maximum number of open connections (0 = unlimited)

Supported drivers: mysql, postgres, clickhouse, mssql, sqlite, oracle, snowflake, trino, gocosmos, spanner.

Conflict Handling

Use the Suffix field to handle conflicts. For example, in PostgreSQL you can use ON CONFLICT (id) DO NOTHING to skip duplicate rows, or ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name to upsert.

tip

When using the SQL Insert processor in a pipeline (rather than as an output), the message content remains unchanged after the insert. This allows you to chain additional processors or route the message to other outputs after the database insert.