datapipe2 0.0.14 → 0.0.15

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/bin/datapipe2 +1 -0
  3. data/lib/fns/db_to_pgsql.rb +27 -0
  4. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0ddf8a65cc8d274b83d25f4fc6e3b19389e2580
4
- data.tar.gz: df9d4b09f603923dd334c78e39dd46ba488055da
3
+ metadata.gz: 51153a4074524efef77b592bdae9b3c10c89a27e
4
+ data.tar.gz: 1ee779ddc7be71437058cc43d5250d354cda9070
5
5
  SHA512:
6
- metadata.gz: b425d4f4f154887bab151c778697fc47b8c5935ad10a6005d0777975c3f0dd81418e78435b1b39e680ed64eecc39aa5bc7e474d999afcd5133d9d4c6d1e0ef32
7
- data.tar.gz: 908b3db47638d1f2b7347b6cc7b103d25514640750b897ad1f0137ebde1ae0e138549a19811d7bd6820bebdbbdf243000e8a77470ed3336407f078b6e2edaa4c
6
+ metadata.gz: 8fd63f863c68496160d05fe4de30985430c019effc6a7bb9129e095f4efa861c894505b832bdbd54e6bf453b6af374ff76f8b490e185bb8f5ae94dbffd60e004
7
+ data.tar.gz: f8c15674e1cd6206a1ff3bec66bb445a592777f9222cfe15444e19206250e1a08c646a3f80da57e16a67e6487bdad2ae024b77ae30addbacefd5d60c3872e9f2
data/bin/datapipe2 CHANGED
@@ -13,5 +13,6 @@ if ARGV.length == 0
13
13
  DataPipe2::Host.new.run
14
14
  else
15
15
  method_name = ARGV.shift
16
+ puts "method_name: #{method_name}"
16
17
  send(method_name, *ARGV)
17
18
  end
@@ -0,0 +1,27 @@
1
+
2
+ def db_to_pgsql(select_sql, table_name, columns)
3
+ s = FluidDb::Db(ENV['SOURCE_DB']) # source
4
+ d = FluidDb::Db(ENV['PGSQL']) # destination
5
+
6
+ d.connection.exec("TRUNCATE TABLE #{table_name}")
7
+ copy_cmd = %{
8
+ COPY #{table_name} (#{columns})
9
+ FROM STDIN
10
+ WITH DELIMITER AS '|'
11
+ CSV;
12
+ }
13
+ d.connection.exec(copy_cmd)
14
+
15
+ results = s.connection.execute(select_sql)
16
+
17
+ count = 0
18
+ results.each(as: :array, cache_rows: false) do |r|
19
+ count += 1
20
+ print '.' if count % 100_000 == 0
21
+ d.connection.put_copy_data "#{r.join('|')}\n"
22
+ end
23
+ puts ""
24
+ d.connection.put_copy_end
25
+
26
+ DataPipe2.log "#{table_name}: #{count}"
27
+ 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.14
4
+ version: 0.0.15
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-08-17 00:00:00.000000000 Z
11
+ date: 2017-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: zero to one for moving data
14
14
  email: guy@guyirvine.com
@@ -22,6 +22,7 @@ files:
22
22
  - lib/fns/db_to_csv.rb
23
23
  - lib/fns/db_to_db.rb
24
24
  - lib/fns/db_to_json.rb
25
+ - lib/fns/db_to_pgsql.rb
25
26
  - lib/fns/mssql_to_pgsql.rb
26
27
  - lib/fns/scp_to_local.rb
27
28
  - lib/fns/smb_to_local.rb
@@ -41,12 +42,12 @@ require_paths:
41
42
  - lib
42
43
  required_ruby_version: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - '>='
45
+ - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
48
  required_rubygems_version: !ruby/object:Gem::Requirement
48
49
  requirements:
49
- - - '>='
50
+ - - ">="
50
51
  - !ruby/object:Gem::Version
51
52
  version: '0'
52
53
  requirements: []