How-to: Use an external database
Connect a flow to your own database server: PostgreSQL, MySQL, MariaDB
or SQL Server. You store its connection details once as a secret,
then run SELECT queries with Database Select and write rows with
Database Insert, Database Upsert or Database Execute. This
guide walks through the full setup.
A SQLite database is a file rather than a server, so the Database nodes do not open one. Read it with Read a File as Data instead.
Step 1 — Create a database credential secret
Section titled “Step 1 — Create a database credential secret”The Database nodes connect with a secret of type Database Credentials, so the password never sits in the flow.
-
Open Connections, then its Secrets tab, and click New secret.
-
Choose Database Credentials as the type.
-
Fill in the connection details:
Field Example Engine PostgreSQL(or MySQL, MariaDB, SQL Server)Host db.example.comPort 5432Dbname productionUsername app_userPassword ••••••

-
Click Create. Note the secret’s name: you select it in the node panel.
Step 2 — Run a SELECT query
Section titled “Step 2 — Run a SELECT query”-
Drop a Database Select node onto the canvas from the node picker’s Storage shelf.


-
Pick your credential secret as the node’s credentials.
-
Write your SQL
SELECT, with a bare:nameplaceholder for each dynamic value:SELECT id, name, emailFROM customersWHERE account_id = :accountId AND active = trueORDER BY id ASCLIMIT 100 -
Add the matching value under Parameters. Each key matches a
:placeholderin the query, and each value is an expression:accountId → {{ $start->accountId }}The database driver binds each value, so the value never becomes part of the SQL text. Do not wrap a placeholder in quotes:
':accountId'is a string literal, not a placeholder.
The node emits a JSON array of row objects.
If you need to run a statement that does not return rows (CREATE,
ALTER, DROP, TRUNCATE, DELETE, or a bulk UPDATE), use
Database Execute instead. It has the same shape and emits
{ "ok": true }.
Step 3 — Insert rows
Section titled “Step 3 — Insert rows”After processing, write results with Database Insert:
- Drop a Database Insert node.
- Select the same credential secret.
- Set Table to the target table name (e.g.
processed_events).
The incoming JSON keys must match the column names. Use a Mapper or Transformer upstream to rename or reshape.
Upsert instead of insert
Section titled “Upsert instead of insert”Use Database Upsert when the same row might arrive more than once. The node uses the table’s unique constraints to decide whether to insert or update — making the flow idempotent.
How long a statement may run
Section titled “How long a statement may run”Each statement a Database node runs may take at most 10 minutes. After
that your database stops it (for SQL Server, its driver does), and the
step fails without a retry, because the same query against the same data
would only be stopped again. Make a slow query cheaper with an index, a
narrower WHERE or a LIMIT, or read the rows in pages.
On MySQL the limit stops a SELECT. An INSERT, UPDATE or DELETE
there is limited only in how long it waits for a lock. PostgreSQL,
MariaDB and SQL Server stop any statement.
Override credentials at runtime
Section titled “Override credentials at runtime”Use extraCredentials to override individual connection settings on
top of the chosen secret. Each key is a connection field such as host
or database, and each value is fixed text merged over the secret’s
value before the node connects:
host → replica.example.comdatabase → analyticsThe values are plain text, not expressions. To point the same flow at a different database server per customer, create one database credentials secret per server and select the matching secret in the node.
Security considerations
Section titled “Security considerations”- Never paste database passwords directly into a node’s configuration — always use a Secret.
- Use least-privilege database users: the account used by query nodes
should only have
SELECT; the account for insert/upsert nodes should only haveINSERT/UPDATE. - Pass every dynamic value through Parameters with a bare
:nameplaceholder in the SQL. The database driver binds each value, so a value containing quotes or SQL fragments cannot change the query. Keep upstream data out of the SQL text itself: echoing a value into the SQL body bypasses binding.
Related
Section titled “Related”- Database Select — full reference.
- Database Execute — full reference.
- Database Insert and Database Upsert — full reference.
- Table Store Query — built-in alternative if external DB is not needed.
- Secrets — credential management.