Skip to main content

SQL Select

Runs a SELECT query against a database and replaces the message with the rows returned. Each row is represented as a JSON object with column names as keys.

FieldTypeDefaultDescription
DriverstringDatabase driver (required)
DSNstringConnection string for the target database (required)
TablestringThe table to query (required)
ColumnsarrayA list of column names to select (required)
WherestringAn optional WHERE clause. Placeholder arguments are populated with Args Mapping
Args MappingBloblangMaps message fields to WHERE clause placeholder arguments
PrefixstringAn optional prefix to prepend before SELECT
SuffixstringAn optional suffix to append to the query
Init StatementstringSQL statement to execute on the first connection
Conn Max Idle TimestringMaximum idle duration before a connection is closed
Conn Max Life TimestringMaximum total lifetime of a connection
Conn Max Idleinteger2Maximum number of idle connections in the pool
Conn Max Openinteger0Maximum number of open connections (0 = unlimited)

Supported drivers: mysql, postgres, clickhouse, mssql, sqlite, oracle, snowflake, trino, gocosmos, spanner.

Result Format

The message payload is replaced with an array of objects, where each object represents a row and column names are used as keys. If the query returns no rows, the message is replaced with an empty array.

Filtering with Where

Use the Where field to filter rows. Placeholder arguments in the WHERE clause are populated from the Args Mapping field. The placeholder style depends on the driver (e.g., ? for MySQL, $1 for PostgreSQL).

tip

Use Prefix and Suffix to add clauses like DISTINCT (prefix) or ORDER BY, LIMIT (suffix) to the generated SELECT query.