kiba-plus 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kiba/plus/source/pg.rb +22 -4
- data/lib/kiba/plus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e1dce9dada36e8dfe05f8fb763290c09fefdddb
|
4
|
+
data.tar.gz: 5cebb5aac9d4e0c5dde7c1a8a75a821e8d47b2d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f0b2212d7d203048424a3d20bdf93b7673bf7fbfd88de8812413998b08464b5a157db45c81b5ed4163051e57e73ff97e2ba4cbac3ff0077f463718cd952c3f
|
7
|
+
data.tar.gz: 71e19684a0fd7893dff572d03afb3af1fe75af5379592b6f0e7d50873abd19b8f7abb127dc2d53a79ab8bdaf07228ac06445332a5adb10c3fd3b0c50e3884339
|
data/lib/kiba/plus/source/pg.rb
CHANGED
@@ -17,7 +17,8 @@ module Kiba
|
|
17
17
|
@options.assert_valid_keys(
|
18
18
|
:connect_url,
|
19
19
|
:schema,
|
20
|
-
:query
|
20
|
+
:query,
|
21
|
+
:stream
|
21
22
|
)
|
22
23
|
@client = PG.connect(connect_url)
|
23
24
|
@client.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
|
@@ -25,9 +26,22 @@ module Kiba
|
|
25
26
|
|
26
27
|
def each
|
27
28
|
Kiba::Plus.logger.info query
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
if stream
|
30
|
+
# http://www.rubydoc.info/github/ged/ruby-pg/PG%2FConnection%3Aset_single_row_mode
|
31
|
+
client.send_query(query)
|
32
|
+
client.set_single_row_mode
|
33
|
+
loop do
|
34
|
+
res = client.get_result or break
|
35
|
+
res.check
|
36
|
+
res.each do |row|
|
37
|
+
yield(row)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
results = client.query(query)
|
42
|
+
results.each do |row|
|
43
|
+
yield(row)
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
33
47
|
|
@@ -40,6 +54,10 @@ module Kiba
|
|
40
54
|
def query
|
41
55
|
options.fetch(:query)
|
42
56
|
end
|
57
|
+
|
58
|
+
def stream
|
59
|
+
options.fetch(:stream, false)
|
60
|
+
end
|
43
61
|
end
|
44
62
|
end
|
45
63
|
end
|
data/lib/kiba/plus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kiba-plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hooopo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kiba
|