datapipe2 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/datapipe2 +1 -0
- data/lib/fns/db_to_pgsql.rb +27 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51153a4074524efef77b592bdae9b3c10c89a27e
|
4
|
+
data.tar.gz: 1ee779ddc7be71437058cc43d5250d354cda9070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd63f863c68496160d05fe4de30985430c019effc6a7bb9129e095f4efa861c894505b832bdbd54e6bf453b6af374ff76f8b490e185bb8f5ae94dbffd60e004
|
7
|
+
data.tar.gz: f8c15674e1cd6206a1ff3bec66bb445a592777f9222cfe15444e19206250e1a08c646a3f80da57e16a67e6487bdad2ae024b77ae30addbacefd5d60c3872e9f2
|
data/bin/datapipe2
CHANGED
@@ -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.
|
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:
|
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: []
|