Run SQL query
BetaChanges data
Reads or changes rows in a MySQL or MariaDB database with SQL you write.
Settings
| Setting | What it is |
|---|---|
| ConnectionRequired | The MySQL connection the step signs in with. |
| Operation | "select" or "execute" |
| QueryRequired | Write values from earlier steps as ?, ? … and list them under Parameters. {{ }} is not filled in here. |
| Parameters | One value per placeholder, in order. Wrap JSON for a json column with CAST(? AS JSON). |
| Max rows | Default 1,000 — up to the workspace limit. |
| If more rows | "fail" or "first" |
Technical details
| Key | Value |
|---|---|
connection | texta connection id from `requires.connections` (provider `mysql`) |
operation | "select" or "execute", by default "select" |
query | textplain text, never `{{ }}` |
params | list of any JSON, by default [] |
maxRows | number, by default 1000 |
ifMoreRows | "fail" or "first", by default "fail"used when `operation` is "select" |
Output
| Field | Type |
|---|---|
rows | array |
rowCountRows returned | number |
columnsColumns — name and type | array |
truncatedMore rows than Max rows — only the first came back | boolean |
affectedRowsRows the statement changed | number |
Sample output, and the expression for each field
- columns
- [0]
- dbType"int"
- name"id"
- type"integer"
- [1]
- dbType"varchar"
- name"email"
- type"text"
- [0]
- rowCount1
- rows
- [0]
- email"ada@example.com"
- id7
- [0]
- truncatedfalse
Errors
When a step of this node stops a run, the run page shows a code. Look it up:
Example step
The step as a flow file holds it. Replace each value in <…>.
{
"config": {
"connection": "<connection id>",
"ifMoreRows": "fail",
"maxRows": 1000,
"operation": "select",
"params": [],
"query": "<query>"
},
"label": "Run SQL query",
"type": "mysql.query",
"version": 1
}