MySQL Queries

MySQL Queries

Certified

Execute multiple SQL statements against MySQL

Runs multiple SQL statements separated by semicolons. To enable multi-statement execution, add allowMultiQueries=true to the JDBC URL. Supports parameterized queries, transactions (default enabled), and all fetch modes. For STORE mode, uses streaming to minimize memory. Supports LOAD DATA LOCAL INFILE via inputFile property.

yaml
type: io.kestra.plugin.jdbc.mysql.Queries

Send a SQL query to a MySQL Database and fetch a row as output.

yaml
id: send_multiple_queries
namespace: test.queries
tasks:
  - id: test_queries_insert
    type: io.kestra.plugin.jdbc.mysql.Queries
    fetchType: FETCH
    url: jdbc:mysql://mysql:3306/kestra?allowMultiQueries=true
    username: "${{secret('MYSQL_USERNAME')}}"
    password: "${{secret('MYSQL_PASSWORD')}}"
    sql: "{{ read('populate.sql') }}"

  - id: test_queries_select
    type: io.kestra.plugin.jdbc.mysql.Queries
    fetchType: FETCH
    url: jdbc:mysql://mysql:3306/kestra
    username: root
    password: "{{ secret('MYSQL_PASSWD') }}"
    sql: |
      SELECT firstName, lastName FROM employee;
      SELECT brand FROM laptop;
Properties

SQL statement(s) to execute

Runs one or more SQL statements rendered with flow variables. Query tasks accept a single statement; Queries tasks can execute multiple statements separated by semicolons

The JDBC URL to connect to the database

SQL to execute after main query in same transaction

Optional SQL executed in the same transaction after the main statement. Useful for marking rows as processed to avoid duplicates; only a single statement is allowed. Commit covers both sql and afterSQL

Default10

Maximum number of pooled connections

Maximum connections held in the pool for a given URL and credentials. Default 10. Increase for flows that run many concurrent queries against the same database to avoid waiting for an available connection. Ignored when connectionPooling is false or for embedded drivers.

Defaulttrue

Reuse database connections via a connection pool

When true (default), connections are pooled and reused across executions, keyed by URL and credentials, removing the connect and TLS-handshake cost on each run. Set to false if your SQL relies on session state persisting on the connection (for example SET search_path, session-scoped temp tables or variables), since pooled connections are reused. Embedded drivers (DuckDB, SQLite, MS Access) never pool regardless of this setting.

Default10000

Number of rows to fetch per database round trip

Controls JDBC fetch size for STORE mode. Default: 10,000 rows; use Integer.MIN_VALUE for MySQL streaming. Ignored for FETCH and FETCH_ONE

DefaultNONE
Possible Values
STOREFETCHFETCH_ONENONE

Result fetching mode

FETCH returns all rows, FETCH_ONE returns the first row only, STORE streams rows to internal storage (ION), NONE returns no data. Default: NONE

Input file for LOAD DATA LOCAL INFILE operations

URI to a file in Kestra's internal storage (kestra://). Used with MySQL's LOAD DATA LOCAL INFILE statement to efficiently load CSV or delimited files into tables

SubTypestring

Output file names to capture after SQL execution

Creates named temporary files in the task working directory before the SQL runs, making their absolute paths available as {{ outputFiles.name }} Pebble variables in the SQL template. Only supported by embedded, in-process drivers (DuckDB, SQLite) where the database engine writes to the same filesystem as the Kestra worker. Remote database drivers (Postgres, MySQL, etc.) do not support this — they execute SQL on a separate server that cannot write to the Kestra worker filesystem.

Named parameter bindings for SQL query

Map of parameter names to values. Use : name placeholders rendered then bound as prepared-statement parameters; supports nulls and typed values

The database user's password

Reference (ref) of the pluginDefaults to apply to this task.

The time zone id to use for date/time manipulation. Default value is the worker's default time zone id

Defaulttrue

Transaction

If one query failed, rollback transactions.

The database user

The list of per-query outputs

Definitions
rowobject

First row of fetched data

Only populated when fetchType is FETCH_ONE

rowsarray
SubTypeobject

List of all fetched rows

Only populated when fetchType is FETCH

sizeinteger

Number of rows fetched

Only populated when fetchType is FETCH or STORE

uristring
Formaturi

URI of stored results in internal storage

Only populated when fetchType is STORE; file is stored in internal storage using ION format

Unitrows

The number of fetched rows.