Help Centre › Building Processes
Execute a database query (MySQL, PostgreSQL, SQL Server, Oracle, MongoDB, SQLite, ODBC).
Add it to a process
In the process designer, open the Add step tab. Find Run database query under Database › Query & Execute, or type its name in the search box, and drag it onto the canvas.
Fields
| Field | Required | What it does |
|---|---|---|
| SQL query | Yes | The SQL query to execute |
| Variable | Yes | Name of the variable where the result will be stored Default: query. |
| Connection name | No | Connection name |
| Max rows | No | Maximum rows to load (0 = all) |
| Timeout | No | Abandon the query after this many seconds (0 = no limit) |
| Parameters (JSON array) | No | Query parameters, one per line (value or key=value) |
| Type | No | The database type; this is the value the bot connects with Choices: MySQL, SQL Server, PostgreSQL, SQLite, ODBC, Oracle, MongoDB. |
| Host | No | The database server hostname or IP address |
| Port | No | The database server port |
| Database | No | The database name to connect to |
| Username | No | The database username |
| Data source name (DSN) | No | ODBC only, and only when this step opens its own connection instead of naming one from a "Connect to database" step. Enter just the name, exactly as it appears in the bot machine's ODBC Data Sources. |
See all Database steps.
Errors
| Error | Description |
|---|---|
| Connection failed | Unable to connect to the database (when using legacy inline connection) |
| Query error | The SQL query contains a syntax error or references invalid objects |
| Authentication failed | The username or password is incorrect (when using legacy inline connection) |
Tips
- Use parameterised queries with %s or ? placeholders to prevent SQL injection
- Use named connections (db-connect) for efficiency – legacy inline mode creates a new connection each time
- Add LIMIT to large result sets to avoid memory issues
- The results can be iterated with the "Each record in a list" loop action