datapipe2 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b439da39202ebb96ba2ed5e435ea9f7c6d6fb033
4
- data.tar.gz: 9210a0a8b53c55b0f0f0d0878448dccf39426e82
3
+ metadata.gz: b7994c281f90be832c80263ab8691c6eed7c870f
4
+ data.tar.gz: 8f8a7b2011195b5158f75fb150d05e3c665a926c
5
5
  SHA512:
6
- metadata.gz: b219e159083257cad08ed7bacb626727a65069fb42bbf1d2dd216c4c35e12c01c2685722240d3cd406ce43da7ad134f86faae2445990cde54a9364775a0bfada
7
- data.tar.gz: 65f0d9f2b40baa71409963126864826c2ec21a9db947e8de2637d4d19771ec19c8b8fbd52c6ca90522b506b66a9f1b35ed574769abe131a92e45589a60a00995
6
+ metadata.gz: 4d62048b6cdeb752db72bb2d6c357151444e5044c7570201c65eaa068dec1e8952ed11382c31e943fce5cbd0209fe6e6776bada78772f0e89c0a65f6b5e7a70f
7
+ data.tar.gz: 4f6b3cc6789fc9f11c18aebe780e4dede215a5eaa4ca89ca3ddc1c5e0d27dbe8fdece19956dbb8ebc6b1d1123190d1e265c3ba9385c0436e72455b7beb71f342
data/lib/datapipe2.rb CHANGED
@@ -10,6 +10,7 @@ module DataPipe2
10
10
  require 'fns/db_to_csv'
11
11
  require 'fns/db_to_json'
12
12
  require 'fns/csv_to_db'
13
+ require 'fns/mssql_to_pgsql'
13
14
 
14
15
  class DataPipe2lineError < StandardError
15
16
  end
@@ -0,0 +1,25 @@
1
+
2
+ def mssql_to_pgsql(mssql, pgsql, select_sql, tableName, columns)
3
+ s = FluidDb::Db(ENV[mssql]) # source
4
+ d = FluidDb::Db(ENV[pgsql]) # destination
5
+
6
+ d.connection.exec("TRUNCATE TABLE #{tableName}")
7
+ copy_cmd = %{
8
+ COPY #{tableName} (#{columns.join(',')})
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
+ d.connection.put_copy_data "#{r.join('|')}\n"
21
+ end
22
+ d.connection.put_copy_end
23
+
24
+ DataPipe2.log "#{tableName}: #{count}"
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datapipe2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
@@ -9,7 +9,49 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-05-02 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fluiddb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: parse-cron
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: zero to one for moving data
14
56
  email: guy@guyirvine.com
15
57
  executables:
@@ -21,6 +63,7 @@ files:
21
63
  - lib/fns/csv_to_db.rb
22
64
  - lib/fns/db_to_csv.rb
23
65
  - lib/fns/db_to_json.rb
66
+ - lib/fns/mssql_to_pgsql.rb
24
67
  - lib/helper_functions.rb
25
68
  - lib/host.rb
26
69
  - lib/jobs.rb