Running SQL queries against databases
-
When creating a new workflow or editing an existing one, in the management console, under Create workflow / Edit workflow, select
Constructor. -
From the Integration steps section on the left side of the screen, drag the
Database Query element to the relevant workflow location in the constructor window.You can drag and drop steps into areas marked by the dotted line in the workflow schema, such as Add a step, etc.
-
In the workflow schema window, click the new Database Query section to select it.
-
At the right of the window, on the Settings tab.
-
In the Step name field, enter a name for the workflow step.
-
Under Connection parameters, select:
-
Connection, to create a connection to the database.-
In the field, specify the following:
-
Database type: Type of the database to connect to.
For a MySQL® database, set the
utf8mb4encoding for field values. -
Host: Database server address.
-
Port: Port for connection to the database.
-
Database: Database name.
-
-
Select Use SSL to connect to the database over SSL.
Selecting this option:
- Enables SSL encryption for a PostgreSQL database.
- Allows secure SSL connections for a ClickHouse® database.
-
Under Authentication, select:
-
Passwordto connect to the database using a username and password. Enter the username and select:-
Lockboxto store the password in a Yandex Lockbox secret. Under Secret, select the secret, its version, and the key used to store the password.If you do not have a Yandex Lockbox secret, click Create to create one.
-
Textto store the password in the specification as text. Enter the password in the Value field.Warning
It is not safe to store your password in the specification in plain text.
-
-
IAM tokento connect to the database using an IAM token of the service account specified in the workflow settings.Note
Authentication by IAM token is only supported for YDB databases.
-
-
-
DSNto specify a database connection string.
-
-
In the SQL query field, specify the SQL query you need to execute.
-
In the Execution method field, select:
Exec: To execute the SQL query and return the service fields only, e.g.,RowsAffectedandLastInsertId.Query: To execute the SQL query and return the result.
-
Optionally, in the Timeout, ms field, set the maximum execution time for the current step.
-
Optionally, to set a custom retry policy for a step, expand the Retry policy section and click
Retry policy. In the form that appears:-
Optionally, in the Initial delay, ms field, set the initial value for a delay between step retries.
-
Optionally, in the Backoff rate field, set the multiplication factor for delay before each step retry.
-
Optionally, in the Maximum delay, ms field, set the value for a maximum delay between step retries.
-
In the Errors field, select the errors for which the step will or will not be retried.
For detailed information about possible errors, see this section.
-
Optionally, in the Maximum number of retries field, set the maximum number of step retry attempts.
-
In the Error selection mode field, select:
INCLUDE: Retry executing a step when errors specified in the Errors field occur.EXCLUDE: To retry executing the step on any errors other than those specified in the Errors field.
If you want to delete a retry policy you created for the step earlier, click
and select Delete in the Retry policy row.If no custom retry policy is configured for a step, the retry policy set for the whole workflow will apply.
-
-
-
Optionally, navigate to the Input tab and set a jq template to filter the workflow state fed into the step.
-
Optionally, navigate to the Output tab and set a jq template to filter the step outputs added into the workflow state.
-
Optionally, add an error transition rule for the step you are creating to handle errors you may get during this step.