Skip to content

Instantly share code, notes, and snippets.

@grimrose
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grimrose/037450ec0773c836a496 to your computer and use it in GitHub Desktop.
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
#!/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