Last active
August 29, 2015 14:19
-
-
Save grimrose/037450ec0773c836a496 to your computer and use it in GitHub Desktop.
embulk-input-jdbc in DSL idea1 https://github.com/embulk/embulk/issues/131
This file contains hidden or 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
#!/usr/bin/env embulk exec | |
require 'embulk' | |
require 'date' | |
today = Date.today | |
yesterday = today -1 | |
from = yesterday.strftime("%Y-%m-%d") | |
to = today.strftime("%Y-%m-%d") | |
select_query = <<EOS | |
select | |
col1 as c1 | |
, col2 as c2 | |
, col3 as c3 | |
from table1 t1 | |
where | |
create_at between #{from} and #{to} | |
EOS | |
embulk = Embulk.new | |
embulk | |
.input("jdbc") | |
.driver_path("/opt/oracle/ojdbc6.jar") | |
.driver_class("oracle.jdbc.driver.OracleDriver") | |
.url("jdbc:oracle:thin:@127.0.0.1:1521:mydb") | |
.user("myuser") | |
.password("mypassword") | |
.query(select_query) | |
.filters([type: "speedometer"]) | |
.output("stdout") | |
.start(ARGV) # run or preview | |
.on_complete(lambda {|config_diff| | |
puts "diff: #{config_diff}" | |
}) | |
.join | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment