sdbcli 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +13 -0
  2. data/bin/sdbcli +1 -1
  3. data/lib/sdbcli/sdb-runner.rb +22 -0
  4. metadata +1 -1
data/README CHANGED
@@ -197,6 +197,19 @@ If '-' is specified as a file name, the input/output of data will become a stand
197
197
  ["100001",
198
198
  ["100002",
199
199
 
200
+ == Save to file
201
+
202
+ ap-northeast-1> select * from employees limit 3 | _('data.txt');
203
+ ap-northeast-1> ! cat data.txt;
204
+ --- |
205
+ [["100000", {"first_name"=>"Hiroyasu", "hire_date"=>"1991-07-02", "birth_date"=>"1956-01-11", "last_name"=>"Emden"}], ["100001", {"first_name"=>"Jasminko", "hire_date"=>"1994-12-25", "birth_date"=>"1953-02-07", "last_name"=>"Antonakopoulos"}], ["100002", {"first_name"=>"Claudi", "hire_date"=>"1988-02-20", "birth_date"=>"1957-03-04", "last_name"=>"Kolinko"}]]
206
+
207
+ ap-northeast-1> select * from employees limit 3 | hire_date.to_i.__('data.txt');
208
+ ap-northeast-1> ! cat data.txt;
209
+ --- |
210
+ [["100000", {"first_name"=>"Hiroyasu", "hire_date"=>"1991-07-02", "birth_date"=>"1956-01-11", "last_name"=>"Emden"}], ["100001", {"first_name"=>"Jasminko", "hire_date"=>"1994-12-25", "birth_date"=>"1953-02-07", "last_name"=>"Antonakopoulos"}], ["100002", {"first_name"=>"Claudi", "hire_date"=>"1988-02-20", "birth_date"=>"1957-03-04", "last_name"=>"Kolinko"}]]
211
+ [1991, 1994, 1988]
212
+
200
213
  == Group By (Aggregate)
201
214
 
202
215
  ap-northeast-1> select * from access_logs limit 30;
data/bin/sdbcli CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
3
3
 
4
- Version = '1.4.6'
4
+ Version = '1.4.7'
5
5
  HISTORY_FILE = File.join((ENV['HOME'] || ENV['USERPROFILE'] || '.'), '.sdbcli_history')
6
6
  HISTSIZE = 500
7
7
  SELECT_LIMIT = 2500
@@ -1,6 +1,28 @@
1
1
  require 'sdbcli/sdb-driver'
2
2
  require 'sdbcli/sdb-parser.tab'
3
3
 
4
+ class Object
5
+ def _(out)
6
+ open(out, 'wb') do |f|
7
+ if block_given?
8
+ f.puts(yield(self))
9
+ else
10
+ f.puts(self.to_s)
11
+ end
12
+ end
13
+ end
14
+
15
+ def __(out)
16
+ open(out, 'ab') do |f|
17
+ if block_given?
18
+ f.puts(yield(self))
19
+ else
20
+ f.puts(self.to_s)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
4
26
  # XXX:
5
27
  class Array
6
28
  def to_i
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdbcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: