Runs an SQL prepared query against a target database for each message and, for queries that return rows, replaces it with the result according to a codec.
If a query contains arguments they can be set as an array of strings supporting
interpolation functions in
The following is a list of supported drivers and their respective DSN formats:
|Driver||Data Source Name Format|
Please note that the
postgres driver enforces SSL by default, you
can override this with the parameter
sslmode=disable if required.
- Table Insert (MySQL)
- Table Query (PostgreSQL)
The following example inserts rows into the table footable with the columns foo, bar and baz populated with values extracted from messages:
Here we query a database for columns of footable that share a
with the message
result_codec is set to
json_array and a
is used in order to insert the resulting array into the original message at the
A database driver to use.
A Data Source Name to identify the target database.
The query to run against the database.
A Bloblang mapping that produces the arguments for the query. The mapping must return an array containing the number of arguments in the query.
Requires version 3.47.0 or newer
A codec to determine how resulting rows are converted into messages.
When a query returns rows they are serialised according to a chosen codec, and the message contents are replaced with the serialised result.
The result of the query is ignored and the message remains unchanged. If your query does not return rows then this is the appropriate codec.
The resulting rows are serialised into an array of JSON objects, where each object represents a row, where the key is the column name and the value is that columns value in the row.