Batch
Certified
Bulk insert rows into PostgreSQL using prepared statements
Batch
Certified
Bulk insert rows into PostgreSQL using prepared statements
yaml
type: io.kestra.plugin.jdbc.postgresql.BatchExamples
yaml
id: postgres_bulk_insert
namespace: company.team
tasks:
- id: query
type: io.kestra.plugin.jdbc.postgresql.Query
url: jdbc:postgresql://dev:5432/
username: "{{ secret('POSTGRES_USERNAME') }}"
password: "{{ secret('POSTGRES_PASSWORD') }}"
sql: |
SELECT *
FROM xref
LIMIT 1500;
fetchType: STORE
- id: update
type: io.kestra.plugin.jdbc.postgresql.Batch
from: "{{ outputs.query.uri }}"
url: jdbc:postgresql://prod:5433/
username: "{{ secret('POSTGRES_USERNAME') }}"
password: "{{ secret('POSTGRES_PASSWORD') }}"
sql: |
insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
yaml
id: postgres_bulk_insert
namespace: company.team
tasks:
- id: query
type: io.kestra.plugin.jdbc.postgresql.Query
url: jdbc:postgresql://dev:5432/
username: "{{ secret('POSTGRES_USERNAME') }}"
password: "{{ secret('POSTGRES_PASSWORD') }}"
sql: |
SELECT *
FROM xref
LIMIT 1500;
fetchType: STORE
- id: update
type: io.kestra.plugin.jdbc.postgresql.Batch
from: "{{ outputs.query.uri }}"
url: jdbc:postgresql://prod:5433/
username: "{{ secret('POSTGRES_USERNAME') }}"
password: "{{ secret('POSTGRES_PASSWORD') }}"
table: xref
yaml
id: postgres_batch
namespace: company.team
tasks:
- id: download_products_csv_file
type: io.kestra.plugin.core.http.Download
uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/products.csv
- id: products_csv_to_ion
type: io.kestra.plugin.serdes.csv.CsvToIon
from: "{{ outputs.download_products_csv_file.uri }}"
- id: postgres_create_table
type: io.kestra.plugin.jdbc.postgresql.Query
url: "jdbc:postgresql://{{ secret('POSTGRES_HOST') }}:5432/postgres"
username: "{{ secret('POSTGRES_USERNAME') }}"
password: "{{ secret('POSTGRES_PASSWORD') }}"
sql: |
CREATE TABLE IF NOT EXISTS products(
product_id varchar(5),
product_name varchar(100),
product_category varchar(50),
brand varchar(50)
)
- id: postgres_batch_insert
type: io.kestra.plugin.jdbc.postgresql.Batch
url: "jdbc:postgresql://{{ secret('POSTGRES_HOST') }}:5432/postgres"
username: "{{ secret('POSTGRES_USERNAME') }}"
password: "{{ secret('POSTGRES_PASSWORD') }}"
from: "{{ outputs.products_csv_to_ion.uri }}"
sql: |
insert into products values (?, ?, ?, ?)
Properties
from *Requiredstring
url *Requiredstring
chunk integerstring
Default
1000columns array
SubTypestring
inputHandling string
Default
AUTOPossible Values
AUTOSTREAMLOCALlocalBufferMaxBytes integerstring
Default
104857600maxRetries integerstring
Default
3password string
resumeOnRetry booleanstring
Default
trueretryBackoff string
Default
PT1SretryScope string
Default
INPUTPossible Values
NONEINPUTALLsql string
ssl booleanstring
Default
falsesslCert string
sslKey string
sslKeyPassword string
sslMode string
Possible Values
DISABLEALLOWPREFERREQUIREVERIFY_CAVERIFY_FULLsslRootCert string
table string
timeZoneId string
username string
Outputs
rowCount integer
updatedCount integer
Metrics
query counter
Unit
queriesrecords counter
Unit
recordsupdated counter
Unit
records