Step - SQL

Module to run SQL queries on a Mysql database.

Settings:
Connection: DSN syntax <username>:<pw>@tcp(<HOST>:<port>)/<dbname>

SQL: Query or queries. If several queries separated by ; (semicolon) provided, they will run in a transaction (please do not provide start transaction / commit or rollback, it's automatically added to provide error handling).

Example for using transactions with last insert ID:
insert into sometable (id,somecolumn) values (null,'somevalue');
set @lastid = last_insert_id(); -- save last insert id into a variable
insert into othertable (id,parent,somecolumn) values (null,@lastid,'some other value');

Example using template loops to generate payload:
UPDATE products SET updated_at = NOW()
WHERE id IN (
{{range $idx, $product := .Payload}}
{{if $idx}},{{end -}}
{{$product.id -}}
{{end -}}
)
Little explanation: templates use go's templating library, ranging through a payload (.Payload ) that's an array of product objects in our example. The array index ($idx ) is used to put comma between the values (first array index is 0, a false value, will not produce a comma, but every other iteration will add the comma). The - (hyphen) inside the {{ }} go template tags before the closing }} will ommit the coming new line character, so the template code is more readable.

Key: The result will be saved into the Header under this key.

As Array: returned records will be processed as one array instead of creating a packet for every record.

Empty OK: incoming packet will be copied to the output even if there was no resulting row

Ignore error: continue running the code even if there was an error while running the query/queries. If several queries were provided, the transaction will not be rolled back but committed.