csvql 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7afe86bb0afc9dfd6ec5d6c256b7a62eda1a7b92
4
- data.tar.gz: 71530ea2eea2fe66ff7078b93b77afb60c14051d
3
+ metadata.gz: 8058641699d9c3f61519e20c5c82bf025d63b2bf
4
+ data.tar.gz: 6ce31e76053b3864bc1f15d34ce93556c9161e6e
5
5
  SHA512:
6
- metadata.gz: f3d40944768905d36db6ce94c70f9c1e9f0cf85c6c281ea87a687d59397c7ac8d5a0c45e7db3f0d7c12dce5b7b09dadbcef32861aa9c6393e80a9e38528d8c77
7
- data.tar.gz: 563cfe718be42fb93f46b3e00207274d47665e04ab47549ceb1c6770ae840f4cfaf70c033b3b2e4cfbdc86f09b4d1cc1c24df784fce9979b1e751f7d859e49a0
6
+ metadata.gz: 73f1c1962c82f3724b310c81ccdf62892f67cd6ad98c4106bab16232d6a62ba7db89dc058319f00b60633bbda794f02979357653642b846beb7339b830502d99
7
+ data.tar.gz: 47a073fe0eccc876cb515db3b894823a0a7149e5be8e1a6eccb00820b38a0d2783cdd8cc4ba77a17586bfdc8b643c66e1826357dd6c4034bb1296ca83926760a
data/README.md CHANGED
@@ -82,7 +82,7 @@ Change output delimiter:
82
82
  3 Charry 48
83
83
  5 Edward 52
84
84
 
85
- Only where clause:
85
+ Only where-clause:
86
86
 
87
87
  $ csvql sample.csv --header --where "age between 30 and 50"
88
88
  1|Anne|33
@@ -91,13 +91,10 @@ Only where clause:
91
91
  Strip spaces around columns:
92
92
 
93
93
  $ cat sample2.csv
94
- name,email,tel
95
94
  Graham , grhm@example.com , 555-1234
96
-
97
- $ csvql sample2.csv --header --select "*"
95
+ $ csvql sample2.csv --select "*"
98
96
  Graham | grhm@example.com | 555-1234
99
-
100
- $ csvql sample2.csv --header --select "*" --strip
97
+ $ csvql sample2.csv --select "*" --strip
101
98
  Graham|grhm@example.com|555-1234
102
99
 
103
100
  Options:
data/lib/csvql/csvql.rb CHANGED
@@ -24,6 +24,11 @@ module Csvql
24
24
  exec "CREATE TABLE IF NOT EXISTS #{@table_name} (#{schema})"
25
25
  end
26
26
 
27
+ def create_alias(table, view="tbl")
28
+ exec "DROP VIEW IF EXISTS #{view}"
29
+ exec "CREATE VIEW #{view} AS SELECT * FROM #{table}"
30
+ end
31
+
27
32
  def drop_table(table_name="tbl")
28
33
  exec "DROP TABLE IF EXISTS #{table_name}"
29
34
  end
data/lib/csvql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Csvql
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/csvql.rb CHANGED
@@ -34,7 +34,11 @@ module Csvql
34
34
 
35
35
  option[:source] ||= argv[0]
36
36
  # option[:where] ||= argv[1]
37
- option[:table_name] ||= "tbl"
37
+ option[:table_name] ||= if option[:save_to] && option[:source] != nil
38
+ File.basename(option[:source].downcase, ".csv").gsub(/\./, "_")
39
+ else
40
+ "tbl"
41
+ end
38
42
  if option[:output_dlm] == 'tab'
39
43
  option[:output_dlm] = "\t"
40
44
  end
@@ -81,6 +85,7 @@ module Csvql
81
85
  tbl = TableHandler.new(option[:save_to], option[:console])
82
86
  tbl.drop_table(option[:table_name]) unless option[:append]
83
87
  tbl.create_table(schema, option[:table_name])
88
+ tbl.create_alias(option[:table_name]) if option[:save_to] && option[:table_name] != "tbl"
84
89
  tbl.exec("PRAGMA synchronous=OFF")
85
90
  tbl.exec("BEGIN TRANSACTION")
86
91
  csvfile.each.with_index(1) do |line,i|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - YANO Satoru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3