-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: blueprint on Postgres Queries task (#47)
- Loading branch information
1 parent
149d67b
commit 1577a31
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
id: postgres-queries | ||
namespace: company.team | ||
|
||
tasks: | ||
- id: init_products | ||
type: io.kestra.plugin.jdbc.postgresql.Queries | ||
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 SERIAL PRIMARY KEY, | ||
product_name varchar(100), | ||
product_category varchar(50), | ||
brand varchar(50) | ||
); | ||
INSERT INTO products VALUES(1, 'streamline turn-key systems','Electronics','gomez') ON CONFLICT (product_id) DO NOTHING; | ||
INSERT INTO products VALUES(2, 'morph viral applications','Household','wolfe') ON CONFLICT (product_id) DO NOTHING; | ||
INSERT INTO products VALUES(3, 'expedite front-end schemas','Household','davis-martinez') ON CONFLICT (product_id) DO NOTHING; | ||
INSERT INTO products VALUES(4, 'syndicate robust ROI','Outdoor','ruiz-price') ON CONFLICT (product_id) DO NOTHING; | ||
fetchType: NONE | ||
|
||
extend: | ||
title: Use Postgres Queries to run multiple queries | ||
description: >- | ||
This flow demonstrates using Postgres Queries task to run multiple | ||
queries in a single task. | ||
This flow can be used a seed flow which can create a table and insert | ||
some sample rows in the table. The flow is idempotent in nature, i.e. | ||
no matter how many times you run the flow, the flow will execute | ||
successfully. Here are the different queries that we execute in the | ||
`init_products` task: | ||
1. The first query creates `products` table if it does not already exist. | ||
In case it exists, it does nothing. | ||
2. The next 4 queries inserts data into the table. In case, the row with | ||
the same primary key already exists, it does nothing. | ||
Thus, the flow can be run multiple times without any side effect. | ||
tags: | ||
- Postgres | ||
ee: false | ||
demo: false | ||
meta_description: This flow uses Postgres Queries task to run multiple queries. |