datapipe2 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datapipe2.rb +1 -0
  3. data/lib/fns/db_to_db.rb +17 -0
  4. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99e153e6dcd823df9fcd95beb13fae4b284d857d
4
- data.tar.gz: 200e0416be134014d3c26b2fe94e14c15c00fc34
3
+ metadata.gz: 50d3264229f3363592e873e03600b7830f205a46
4
+ data.tar.gz: d1226748e0b7892cb315b0082fe901ea397a14e0
5
5
  SHA512:
6
- metadata.gz: 2d5bc715fc364a5f1f58acc137cf6b27c7dfa1dac678978727a9835734c670e3fd0dec9d39779e4557b68c6f073803638cf6c7c4b7998acf95c4b1b70f205c19
7
- data.tar.gz: 6d7c15771d7431d6b0dbeef363a1c9210182f2ff647c38410ec36ea79deafc00c12d55140a29435da31ce87c6d3200ce96a65b91c923c4b229263af422b60698
6
+ metadata.gz: 6b444290a548ea22eefadb745da1fd8042f2d56bf020a894360cf04c29372ad71d893533fe22c965e16780948a9993fe6bcd11f3c3fa4e5bdb68c977c3b5577c
7
+ data.tar.gz: 8405a58c633c023750110419d10fd1bdd0cd2b9ffe86a769f2b48d075189ead6730663e5f040864766add4c2bb0f1d709c4fb5d2deb0ee7af41f35f2c80116f4
data/lib/datapipe2.rb CHANGED
@@ -12,6 +12,7 @@ module DataPipe2
12
12
  require 'fns/csv_to_db'
13
13
  require 'fns/mssql_to_pgsql'
14
14
  require 'fns/smb_to_local'
15
+ require 'fns/db_to_db'
15
16
 
16
17
  class DataPipe2lineError < StandardError
17
18
  end
@@ -0,0 +1,17 @@
1
+
2
+ def db_to_db(select_sql, table_name, columns)
3
+ s = FluidDb::Db(ENV['SOURCE_DB']) # source
4
+ d = FluidDb::Db(ENV['DEST_DB']) # destination
5
+
6
+ insert_cmd = %{
7
+ INSERT INTO #{table_name} (#{columns})
8
+ VALUES (#{Array.new(columns.split(',').length, '?').join(',')})
9
+ }
10
+
11
+ rst = s.queryForResultset(select_sql)
12
+ rst.each do |row|
13
+ d.execute(insert_cmd, row.values)
14
+ end
15
+
16
+ DataPipe2.log "#{table_name}: #{rst.length}"
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datapipe2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-01 00:00:00.000000000 Z
11
+ date: 2016-07-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: zero to one for moving data
14
14
  email: guy@guyirvine.com
@@ -20,6 +20,7 @@ files:
20
20
  - lib/datapipe2.rb
21
21
  - lib/fns/csv_to_db.rb
22
22
  - lib/fns/db_to_csv.rb
23
+ - lib/fns/db_to_db.rb
23
24
  - lib/fns/db_to_json.rb
24
25
  - lib/fns/mssql_to_pgsql.rb
25
26
  - lib/fns/smb_to_local.rb