kiba-plus 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kiba/plus/destination/pg.rb +11 -6
- data/lib/kiba/plus/job.rb +2 -2
- data/lib/kiba/plus/source/pg.rb +2 -2
- data/lib/kiba/plus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd0ab521f8e00c7b382e0837b43ac63d46fa04d4
|
|
4
|
+
data.tar.gz: 6a0116b43920b28f6cd4c5f69f108c3d1c554006
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67cc2a0d8b6c00951bacdfde6b9452a8057a5f7c274aa5e055ae1c0c759becd9bae7b816f380b96bb5483a4683881bd8956242d28792c3d5c28fa1418a690afc
|
|
7
|
+
data.tar.gz: f417fe27d5b199ef50f76e1a1441d7a1a44e41af3bfd92542b6fb4fe3e27dd423b75aa72026de781492924993b0ae867a2b3ff574f3d7235f4995cd465558bc0
|
|
@@ -9,12 +9,11 @@ module Kiba::Plus::Destination
|
|
|
9
9
|
@options.assert_valid_keys(
|
|
10
10
|
:connect_url,
|
|
11
11
|
:schema,
|
|
12
|
-
:
|
|
13
|
-
:prepare_sql,
|
|
12
|
+
:table_name,
|
|
14
13
|
:columns
|
|
15
14
|
)
|
|
16
15
|
@conn = PG.connect(connect_url)
|
|
17
|
-
@conn.exec "SET search_path TO %s" % [ options
|
|
16
|
+
@conn.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
|
|
18
17
|
init
|
|
19
18
|
end
|
|
20
19
|
|
|
@@ -43,16 +42,22 @@ module Kiba::Plus::Destination
|
|
|
43
42
|
options.fetch(:connect_url)
|
|
44
43
|
end
|
|
45
44
|
|
|
45
|
+
def table_name
|
|
46
|
+
options.fetch(:table_name)
|
|
47
|
+
end
|
|
48
|
+
|
|
46
49
|
def prepare_name
|
|
47
|
-
options.fetch(:prepare_name,
|
|
50
|
+
options.fetch(:prepare_name, table_name + "_stmt")
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
def prepare_sql
|
|
51
|
-
|
|
54
|
+
sql = <<-SQL
|
|
55
|
+
INSERT INTO #{table_name} (#{columns.join(', ') }) VALUES (#{columns.each_with_index.map { |_, i| "$#{i + 1}" }.join(', ')});
|
|
56
|
+
SQL
|
|
52
57
|
end
|
|
53
58
|
|
|
54
59
|
def columns
|
|
55
60
|
options.fetch(:columns)
|
|
56
61
|
end
|
|
57
62
|
end
|
|
58
|
-
end
|
|
63
|
+
end
|
data/lib/kiba/plus/job.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Kiba
|
|
|
18
18
|
@client = Mysql2::Client.new(mysql2_connect_hash(connect_url))
|
|
19
19
|
elsif url.scheme =~ /postgres/i
|
|
20
20
|
@client = PG.connect(connect_url)
|
|
21
|
-
@client.exec "SET search_path TO %s" % [ options
|
|
21
|
+
@client.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
|
|
22
22
|
else
|
|
23
23
|
raise 'No Imp!'
|
|
24
24
|
end
|
|
@@ -147,4 +147,4 @@ module Kiba
|
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
|
-
end
|
|
150
|
+
end
|
data/lib/kiba/plus/source/pg.rb
CHANGED
|
@@ -15,7 +15,7 @@ module Kiba
|
|
|
15
15
|
:query
|
|
16
16
|
)
|
|
17
17
|
@client = PG.connect(connect_url)
|
|
18
|
-
@client.exec "SET search_path TO %s" % [ options
|
|
18
|
+
@client.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def each
|
|
@@ -37,4 +37,4 @@ module Kiba
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
-
end
|
|
40
|
+
end
|
data/lib/kiba/plus/version.rb
CHANGED