Skip to content

Instantly share code, notes, and snippets.

@hiroyuki-sato
Created April 11, 2017 08:16
Show Gist options
  • Save hiroyuki-sato/d3d1b79c594801a85f54186f707db4ba to your computer and use it in GitHub Desktop.
Save hiroyuki-sato/d3d1b79c594801a85f54186f707db4ba to your computer and use it in GitHub Desktop.
embulk-input-postgresql test

prepare

create table sample(
  id integer not null,
  col_text text null,
  col_double double precision null,
  col_time timestamp with time zone null
);
insert into sample values(1,'text',1.234,'2017-04-12');
create view sample_view as select * from sample;

select from table

in:
  type: postgresql
  user: user
  port: 5432
  host: xxx.xxx.xxx.xxx
  table: sample
  database: embulk_test
out:
  type: stdout
2017-04-11 17:12:42.560 +0900: Embulk v0.8.18
2017-04-11 17:12:43.617 +0900 [INFO] (0001:preview): Loaded plugin embulk-input-postgresql (0.8.2)
2017-04-11 17:12:43.698 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
2017-04-11 17:12:43.810 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
2017-04-11 17:12:43.812 +0900 [INFO] (0001:preview): SQL: DECLARE cur NO SCROLL CURSOR FOR SELECT * FROM "sample"
2017-04-11 17:12:43.814 +0900 [INFO] (0001:preview): SQL: FETCH FORWARD 10000 FROM cur
2017-04-11 17:12:43.816 +0900 [INFO] (0001:preview): > 0.00 seconds
2017-04-11 17:12:43.818 +0900 [INFO] (0001:preview): SQL: FETCH FORWARD 10000 FROM cur
2017-04-11 17:12:43.818 +0900 [INFO] (0001:preview): > 0.00 seconds
+---------+-----------------+-------------------+-------------------------+
| id:long | col_text:string | col_double:double |      col_time:timestamp |
+---------+-----------------+-------------------+-------------------------+
|       1 |            text |             1.234 | 2017-04-11 15:00:00 UTC |
+---------+-----------------+-------------------+-------------------------+

select from view

in:
  type: postgresql
  user: user
  port: 5432
  host: xxx.xxx.xxx.xxx
  table: sample_view
  database: embulk_test
out:
  type: stdout
embulk preview test.yml
2017-04-11 17:12:59.444 +0900: Embulk v0.8.18
2017-04-11 17:13:00.646 +0900 [INFO] (0001:preview): Loaded plugin embulk-input-postgresql (0.8.2)
2017-04-11 17:13:00.731 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
2017-04-11 17:13:00.832 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
2017-04-11 17:13:00.834 +0900 [INFO] (0001:preview): SQL: DECLARE cur NO SCROLL CURSOR FOR SELECT * FROM "sample_view"
2017-04-11 17:13:00.836 +0900 [INFO] (0001:preview): SQL: FETCH FORWARD 10000 FROM cur
2017-04-11 17:13:00.838 +0900 [INFO] (0001:preview): > 0.00 seconds
2017-04-11 17:13:00.841 +0900 [INFO] (0001:preview): SQL: FETCH FORWARD 10000 FROM cur
2017-04-11 17:13:00.842 +0900 [INFO] (0001:preview): > 0.00 seconds
+---------+-----------------+-------------------+-------------------------+
| id:long | col_text:string | col_double:double |      col_time:timestamp |
+---------+-----------------+-------------------+-------------------------+
|       1 |            text |             1.234 | 2017-04-11 15:00:00 UTC |
+---------+-----------------+-------------------+-------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment