Skip to content

Database Destination

The Database destination writes processed messages to a relational database using parameterized SQL statements. It supports PostgreSQL, MySQL, and Microsoft SQL Server with connection pooling and environment-variable substitution for credentials.

Add a Database destination to a channel in intu.yaml:

destinations:
- name: patient-db
type: database
properties:
driver: postgres
dsn: "postgres://${DB_USER}:${DB_PASS}@db.hospital.local:5432/clinical?sslmode=require"
statement: |
INSERT INTO patients (mrn, first_name, last_name, dob)
VALUES ($1, $2, $3, $4)
PropertyTypeDefaultDescription
driverstring(required)Database driver: postgres, mysql, or mssql.
dsnstring(required)Data source name (connection string). Supports ${VAR} substitution.
statementstring(required)Parameterized SQL statement to execute for each message.
max_connsinteger5Maximum number of open connections in the pool.
max_idle_connsinteger2Maximum number of idle connections retained.
conn_max_lifetime_msinteger300000Maximum lifetime of a connection before it is closed and replaced (5 minutes default).
DriverFormatExample
postgrespostgres://user:pass@host:port/dbname?sslmode=requirepostgres://${DB_USER}:${DB_PASS}@db:5432/clinical?sslmode=require
mysqluser:pass@tcp(host:port)/dbname?tls=true${DB_USER}:${DB_PASS}@tcp(db:3306)/clinical?tls=true
mssqlsqlserver://user:pass@host:port?database=dbname&encrypt=truesqlserver://${DB_USER}:${DB_PASS}@db:1433?database=clinical&encrypt=true

A Database destination that upserts patient records into PostgreSQL:

destinations:
- name: patient-upsert
type: database
properties:
driver: postgres
dsn: "postgres://${DB_USER}:${DB_PASS}@db.hospital.local:5432/clinical?sslmode=require"
statement: |
INSERT INTO patients (mrn, first_name, last_name, dob, updated_at)
VALUES ($1, $2, $3, $4, NOW())
ON CONFLICT (mrn)
DO UPDATE SET
first_name = EXCLUDED.first_name,
last_name = EXCLUDED.last_name,
dob = EXCLUDED.dob,
updated_at = NOW()
max_conns: 10
max_idle_conns: 3
conn_max_lifetime_ms: 600000