Database: Run database query

Execute a database query (MySQL, PostgreSQL, SQL Server, Oracle, MongoDB, SQLite, ODBC).

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

FieldRequiredWhat it does
SQL queryYesThe SQL query to execute
VariableYesName of the variable where the result will be stored Default: query.
Connection nameNoConnection name
Max rowsNoMaximum rows to load (0 = all)
TimeoutNoAbandon the query after this many seconds (0 = no limit)
Parameters (JSON array)NoQuery parameters, one per line (value or key=value)
TypeNoThe database type; this is the value the bot connects with Choices: MySQL, SQL Server, PostgreSQL, SQLite, ODBC, Oracle, MongoDB.
HostNoThe database server hostname or IP address
PortNoThe database server port
DatabaseNoThe database name to connect to
UsernameNoThe database username
Data source name (DSN)NoODBC 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

ErrorDescription
Connection failedUnable to connect to the database (when using legacy inline connection)
Query errorThe SQL query contains a syntax error or references invalid objects
Authentication failedThe 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

Related functions

Get started

See it working on your own data

Everything documented here ships with the platform – try the document tools free, or have your first automation working in 7 days.