~4 min9 / 12

Database Activities

Run SQL queries against SQL Server, SQLite, MySQL, and PostgreSQL directly from your workflows. All database activities share a connection string and support parameterised queries to prevent SQL injection.

Connection String Formats

Paste one of these into the Connection String field of any database activity:

DatabaseConnection String
SQL ServerServer=myserver;Database=mydb;User Id=myuser;Password=mypass;
SQLiteData Source=C:\path\to\mydb.sqlite;
MySQLServer=myserver;Database=mydb;Uid=myuser;Pwd=mypass;
PostgreSQLHost=myserver;Database=mydb;Username=myuser;Password=mypass;
Secure CredentialsNever hard-code passwords in a connection string. Use {{secret:db_password}} to pull from the Orchestrator Secrets Vault at runtime.

ExecuteQuery (SELECT)

Runs a SELECT statement and returns a DataTable variable containing the result set.

ParameterTypeRequiredDescription
Connection StringStringYesDatabase connection string (see above)
SQLStringYesThe SELECT query to execute
ParametersKey–Value pairsNoNamed parameters for safe query binding
TimeoutInt32NoCommand timeout in seconds (default: 30)
Connection NameStringNoReuse an open connection — all activities with the same name share a connection
OutputDataTable variableYesResult set
workflow
1ExecuteQuery:
2 ConnectionString: "Server=localhost;Database=orders_db;User Id=app;Password={{secret:db_password}};"
3 SQL: "SELECT order_id, customer, total FROM orders WHERE status = @status AND created > @since"
4 Parameters:
5 @status: "shipped"
6 @since: "2026-01-01"
7 Output: ordersTable
8 
9ForEachRow: ordersTable
10 Log: "Order #{{CurrentRow.order_id}} — {{CurrentRow.customer}} — ${{CurrentRow.total}}"

ExecuteNonQuery (INSERT / UPDATE / DELETE)

Runs a statement that modifies data and returns the number of affected rows as an Int32.

ParameterTypeRequiredDescription
Connection StringStringYesDatabase connection string
SQLStringYesThe INSERT, UPDATE, or DELETE statement
ParametersKey–Value pairsNoNamed parameters
OutputInt32 variableYesNumber of rows affected
workflow
1ExecuteNonQuery:
2 ConnectionString: "Server=localhost;Database=orders_db;User Id=app;Password={{secret:db_password}};"
3 SQL: "UPDATE orders SET status = @newStatus WHERE order_id = @orderId"
4 Parameters:
5 @newStatus: "completed"
6 @orderId: "{{currentOrderId}}"
7 Output: rowsAffected
8 
9If: rowsAffected == 0
10 Log: "Warning — order {{currentOrderId}} not found"
Always Use Parameterised QueriesNever concatenate user data into SQL strings. Use @parameterName in your SQL and add corresponding key-value pairs in the Parameters section. This prevents SQL injection attacks.

Reusing Connections

If your workflow runs multiple database activities against the same server, set the Connection Name property to the same string (e.g., main_db) on each activity. The engine reuses the open connection instead of opening a new one each time, which is faster and avoids connection-pool exhaustion.

Working with DataTable Output

Once you have a DataTable from ExecuteQuery, you can:

ActionHow
Iterate rowsUse a ForEachRow activity — access columns via CurrentRow.column_name
Export to ExcelPass the DataTable to a WriteRange activity
Filter rowsUse a FilterDataTable activity with column conditions
Get row countAccess myTable.RowCount as an Int32 variable
Was this helpful?