nyno-sql
nyno-sql — Execute arbitrary SQL queries on PostgreSQL
Description
- step: nyno-sql
args:
- '${QUERY}'
- '${PARAMS}' # optional
The nyno-sql step executes arbitrary SQL queries on the PostgreSQL database connected via db_nyno_log.
- Automatically uses the persistent PostgreSQL client initialized by
App. - Supports parameterized queries to prevent SQL injection.
- Stores query results in workflow context (
${prev}by default).
Usage in a workflow YAML:
workflow:
- step: nyno-sql
args:
- "SELECT * FROM json_storage WHERE data->>'user' = $1"
- ['Alice']
Parameters
| Parameter | Type | Description |
|---|---|---|
query |
string |
The SQL query to execute. Use $1, $2, … for parameter placeholders. |
params |
array |
Optional array of parameter values to bind to the query placeholders. Defaults to empty array. |
Context requirements / environment:
- PostgreSQL client (
db_nyno_log) must be initialized (e.g., viasetup.shornyno-sql-insertworkflow steps).
Return Values
- Returns
0if the query returns rows,1if no rows are returned. - Query result rows are stored in context (
${prev}by default, or custom viaset_context):
[
{ "data": { "user": "Alice", "action": "login", "timestamp": "2025-12-27T12:00:00Z" } },
{ "data": { "user": "Alice", "action": "logout", "timestamp": "2025-12-27T12:05:00Z" } }
]
- If the query returns no data, context is still set to an empty array.
Behavior
- Executes SQL queries against the
db_nyno_logPostgreSQL database. - Supports both raw queries and parameterized queries.
- Stores query results in context for use in downstream workflow steps.
- Returns
0for queries with rows,1for queries with no results.
Examples
Example #1 — Select with parameters
workflow:
- step: nyno-sql
args:
- "SELECT * FROM json_storage WHERE data->>'user' = $1"
- ['Alice']
Stores matching rows in ${prev}.
Example #2 — Select all rows
workflow:
- step: nyno-sql
args:
- "SELECT * FROM json_storage"
Stores all rows in ${prev}.
Notes
- Ensure the PostgreSQL client (
db_nyno_log) is initialized before using this step. - Use parameterized queries (
$1,$2, …) to safely pass user input. set_contextcan be used to store results in a custom context key instead of${prev}.
See Also
- nyno-sql-insert: Insert JSON data into PostgreSQL.
- nyno-file-read / nyno-file-write: Read or save query results to files.