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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccfeb1e0e0d0597a534850d23ce04f5cee5114ec
4
- data.tar.gz: c40ac9e7aefeaea658074cc2000978476ad4f549
3
+ metadata.gz: 0e1dce9dada36e8dfe05f8fb763290c09fefdddb
4
+ data.tar.gz: 5cebb5aac9d4e0c5dde7c1a8a75a821e8d47b2d5
5
5
  SHA512:
6
- metadata.gz: 5b5fc63b73b49e96f1a82bdd8be7b763c891787fb357d8fb37e3e98f4393a91ea8d65f23250cb26dca83fae05d6e79f3e3a0359044d1ab9e9e39b2a31728814f
7
- data.tar.gz: 96f7bb6eb6c0273f24f0d71d04417d50f9e7ab548309503d56201c2a78c63b2117a6f42e9f79ea9a5c0b4ebd86385ba4989ea2e45015d1e65ce7f4241fc776cb
6
+ metadata.gz: 47f0b2212d7d203048424a3d20bdf93b7673bf7fbfd88de8812413998b08464b5a157db45c81b5ed4163051e57e73ff97e2ba4cbac3ff0077f463718cd952c3f
7
+ data.tar.gz: 71e19684a0fd7893dff572d03afb3af1fe75af5379592b6f0e7d50873abd19b8f7abb127dc2d53a79ab8bdaf07228ac06445332a5adb10c3fd3b0c50e3884339
@@ -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
- results = client.query(query)
29
- results.each do |row|
30
- yield(row)
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
@@ -1,5 +1,5 @@
1
1
  module Kiba
2
2
  module Plus
3
- VERSION = "0.1.14"
3
+ VERSION = "0.1.15"
4
4
  end
5
5
  end
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.14
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-21 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kiba