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
Driverstring—Database driver (required)
DSNstring—Connection string for the target database (required)
Tablestring—The table to query (required)
Columnsarray—A list of column names to select (required)
Wherestring—An optional WHERE clause. Placeholder arguments are populated with Args Mapping
Args MappingBloblang—Maps message fields to WHERE clause placeholder arguments
Prefixstring—An optional prefix to prepend before SELECT
Suffixstring—An optional suffix to append to the query
Init Statementstring—SQL statement to execute on the first connection
Conn Max Idle Timestring—Maximum idle duration before a connection is closed
Conn Max Life Timestring—Maximum 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.