db_write
The raw-SQL escape hatch for writes (multi-table statements, UPDATE … FROM,
SQL functions in SET, DDL). Runs an INSERT/UPDATE/DELETE against a SQL
connector and writes { "rows_affected": N }. Note: the author writes
dialect-specific SQL, and a connector can disable this function entirely through its raw_write operation gate.
Synopsis
{
"name": "db_write",
"input": {
"connector": "primary-db",
"query": "INSERT INTO orders (id, total) VALUES (?, ?)",
"params": [
{
"var": "data.order.id"
},
{
"var": "data.order.total"
}
],
"output": "data.write_result"
}
}
Description
db_write is a connector function. It names a connector for its credentials and endpoint. Orion validates its input when the workflow is saved, and the call runs through the connector’s circuit breaker.
Retry safety: depends_on sql. See Retry safety for what the answer costs.
An INSERT also carries last_insert_id on MySQL and SQLite, the same key
data_write reports. PostgreSQL does not report one; it uses RETURNING, which the portable dialect supports. The key appears for an INSERT/REPLACE only. SQLite’s last_insert_rowid belongs to the connection, so after an UPDATE it would report whatever an earlier insert
on that pooled connection left behind.
Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
connector | string | yes | — | Name of the SQL connector |
query | string | yes | — | INSERT/UPDATE/DELETE statement with bind placeholders |
params | array | no | — | Values bound to the placeholders, in order. Each element folds {"var": …} and nothing else — an operator written inline binds as a literal object, which lint reports as logic.unresolvable; compute it in a map task first |
output | string | JSONLogic | no | "data" | Dotted path where { "rows_affected": N } (plus last_insert_id after an insert) is written |
Examples
{
"name": "db_write",
"input": {
"connector": "primary-db",
"query": "INSERT INTO orders (id, total) VALUES (?, ?)",
"params": [{ "var": "data.order.id" }, { "var": "data.order.total" }],
"output": "data.write_result"
}
}
Related
- Connectors: why credentials and endpoints live on a connector.
- Connect a database or API: creating the connector this function names.
- Task functions: the whole catalogue, and each function’s retry safety.
- Portable data dialect › Connector operation gates: the
raw_writegate that can disable this function. - Connector types: the connector fields, retries and circuit breakers behind the call.
Last verified 14 September 2026