Batch
Run a MySQL batch-query.
type: "io.kestra.plugin.jdbc.mysql.Batch"
Examples
Fetch rows from a table, and bulk insert them to another one.
id: mysql_batch
namespace: company.team
tasks:
- id: query
type: io.kestra.plugin.jdbc.mysql.Query
url: jdbc:mysql://127.0.0.1:3306/
username: mysql_user
password: mysql_password
sql: |
SELECT *
FROM xref
LIMIT 1500;
fetchType: STORE
- id: update
type: io.kestra.plugin.jdbc.mysql.Batch
from: "{{ outputs.query.uri }}"
url: jdbc:mysql://127.0.0.1:3306/
username: mysql_user
password: mysql_password
sql: |
insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
Fetch rows from a table, and bulk insert them to another one, without using sql query.
id: mysql_batch
namespace: company.team
tasks:
- id: query
type: io.kestra.plugin.jdbc.mysql.Query
url: jdbc:mysql://127.0.0.1:3306/
username: mysql_user
password: mysql_password
sql: |
SELECT *
FROM xref
LIMIT 1500;
fetchType: STORE
- id: update
type: io.kestra.plugin.jdbc.mysql.Batch
from: "{{ outputs.query.uri }}"
url: jdbc:mysql://127.0.0.1:3306/
username: mysql_user
password: mysql_password
table: xref
Properties
from *Requiredstring
Source file URI
Pebble expression referencing an Internal Storage URI e.g. {{ outputs.mytask.uri }}
.
url *Requiredstring
The JDBC URL to connect to the database.
chunk integerstring
1000
The size of chunk for every bulk request.
columns array
The columns to be inserted.
If not provided, ?
count need to match the from
number of columns.
password string
The database user's password.
sql string
Insert query to be executed.
The query must have as many question marks as the number of columns in the table. Example: 'insert into <table_name> values( ? , ? , ? )' for 3 columns. In case you do not want all columns, you need to specify it in the query in the columns property Example: 'insert into <table_name> (id, name) values( ? , ? )' for inserting data into 2 columns: 'id' and 'name'.
table string
The table from which column names will be retrieved.
This property specifies the table name which will be used to retrieve the columns for the inserted values.
You can use it instead of specifying manually the columns in the columns
property. In this case, the sql
property can also be omitted, an INSERT statement would be generated automatically.
timeZoneId string
The time zone id to use for date/time manipulation. Default value is the worker's default time zone id.
username string
The database user.
Outputs
rowCount integer
The rows count.
updatedCount integer
The updated rows count.