Source
yaml
id: copyin-postgres
namespace: company.team
tasks:
- id: download
type: io.kestra.plugin.core.http.Download
uri: https://raw.githubusercontent.com/lukes/ISO-3166-Countries-with-Regional-Codes/master/all/all.csv
- id: create_table
type: io.kestra.plugin.jdbc.postgresql.Query
url: jdbc:postgresql://sample_postgres:5433/world
username: postgres
password: postgres
sql: |
CREATE TABLE IF NOT EXISTS country_referential(
name VARCHAR,
"alpha-2" VARCHAR,
"alpha-3" VARCHAR,
"country-code" VARCHAR,
"iso_3166-2" VARCHAR,
region VARCHAR,
"sub-region" VARCHAR,
"intermediate-region" VARCHAR,
"region-code" VARCHAR,
"sub-region-code" VARCHAR,
"intermediate-region-code" VARCHAR
);
- id: copyin
type: io.kestra.plugin.jdbc.postgresql.CopyIn
url: jdbc:postgresql://sample_postgres:5433/world
username: postgres
password: postgres
format: CSV
from: "{{ outputs.download.uri }}"
table: country_referential
header: true
- id: read
type: io.kestra.plugin.jdbc.postgresql.Query
url: jdbc:postgresql://sample_postgres:5433/world
username: postgres
password: postgres
sql: SELECT * FROM country_referential LIMIT 10
fetchType: FETCH
About this blueprint
Postgres SQL Outputs
This blueprint shows how to copy a CSV file into a Postgres table.
More Related Blueprints