slyce 1.3.3 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/slyce +20 -19
- data/bin/slyced +1 -1
- data/slyce.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1611ad48c69cfc3485861a330287d6afb01e7822d060175cc8d312d92327b49b
|
4
|
+
data.tar.gz: fba5942e20444188dc70d721bae61d4d7ef6d7de933735f5f2b7a8c7d25335b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 881a62062b6cc066dc0cb4e06a9d399e18c760db70517564d6c72e32424ac610823819b5d4201d29ea3275b8414981e43e3b205107a470198049b0a2f7b5d8ff
|
7
|
+
data.tar.gz: 363c50d513e9ee5ee829300550aad0d6f3fb98b5fafa0bcaa9733900028a714392e1052db8aa2af004ae3ca8bbc32925288c063374ab14683967002decae18e2
|
data/bin/slyce
CHANGED
@@ -11,7 +11,7 @@ dbas = nil
|
|
11
11
|
tabl = nil
|
12
12
|
|
13
13
|
OptionParser.new.instance_eval do
|
14
|
-
@version = "1.3.
|
14
|
+
@version = "1.3.5"
|
15
15
|
@banner = "usage: #{program_name} [options] <database> <table>"
|
16
16
|
|
17
17
|
on "--csv" , "Output comma separated values"
|
@@ -43,7 +43,7 @@ want = opts[:extract ].to_s.downcase.split(",")
|
|
43
43
|
natu = opts[:natural ]
|
44
44
|
show = opts[:rows ]
|
45
45
|
hide = opts[:suppress]
|
46
|
-
filt = opts[:where ] and filt = "
|
46
|
+
filt = opts[:where ] and filt = "\nwhere\n #{filt}"
|
47
47
|
|
48
48
|
dbas ||= ARGV.shift or abort "no database given"
|
49
49
|
tabl ||= ARGV.shift or opts[:tables] or !want.empty? or abort "no table given"
|
@@ -98,7 +98,9 @@ else
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
# connect to database and get server version
|
101
102
|
conn = Mysql2::Client.new(**conf, as: :array)
|
103
|
+
ver5 = conn.server_info[:version] =~ /^5/
|
102
104
|
|
103
105
|
# dump database schema or show table names
|
104
106
|
if tabl.nil? || opts[:tables] || opts[:dump]
|
@@ -154,8 +156,7 @@ if xprt
|
|
154
156
|
select
|
155
157
|
#{list}
|
156
158
|
from
|
157
|
-
`#{tabl}
|
158
|
-
#{filt}
|
159
|
+
`#{tabl}`#{filt}
|
159
160
|
|
160
161
|
seps = xcsv ? "," : xtsv ? "\t" : xpsv ? "|" : abort("unknown separator #{seps.inspect}")
|
161
162
|
|
@@ -169,36 +170,36 @@ if xprt
|
|
169
170
|
exit
|
170
171
|
end
|
171
172
|
|
172
|
-
# MySQL 5.7 compatible version (still need to find replacement for regexp_instr)
|
173
|
-
# -if((`#{name}` rlike '^[-+]?((0|([1-9]\\\\d*)(\\\\.\\\\d*)?)|((0|([1-9]\\\\d*))\\\\.\\\\d+))$'), `#{name}` + 0, null) desc,
|
174
|
-
# -if((`#{name}` rlike '^0\\\\d+$'), length(`#{name}`), null) desc,
|
175
|
-
# -if((`#{name}` rlike '^\\\\d'), regexp_instr(`#{name}`, '[^\\\\d]'), null) desc,
|
176
|
-
|
177
173
|
want.each do |name|
|
178
174
|
sort = natu ? "" : "cnt desc,"
|
179
|
-
|
180
|
-
|
175
|
+
like =(ver5 ? <<~"" : <<~"").gsub(/(.)^/m, '\1 ').rstrip
|
176
|
+
-if((`#{name}` rlike '^[-+]?((0|([1-9][0-9]*)(\\\\.[0-9]*)?)|((0|([1-9][0-9]*))\\\\.[0-9]+))$'), `#{name}` + 0, null) desc,
|
177
|
+
-if((`#{name}` rlike '^0[0-9]+$'), length(`#{name}`), null) desc,
|
178
|
+
-if((`#{name}` rlike '^[0-9]'), length(concat("1", `#{name}`) + 0), null) desc,
|
179
|
+
|
180
|
+
-if(regexp_like(`#{name}`, '^[-+]?((0|([1-9]\\\\d*)(\\\\.\\\\d*)?)|((0|([1-9]\\\\d*))\\\\.\\\\d+))$'), `#{name}` + 0, null) desc,
|
181
|
+
-if(regexp_like(`#{name}`, '^0\\\\d+$'), length(`#{name}`), null) desc,
|
182
|
+
-if(regexp_like(`#{name}`, '^\\\\d'), regexp_instr(`#{name}`, '[^\\\\d]'), null) desc,
|
183
|
+
|
184
|
+
data = conn.sql(<<~"".rstrip).to_a
|
181
185
|
select
|
182
186
|
count(*) as cnt,
|
183
187
|
`#{name}` as val
|
184
188
|
from
|
185
|
-
`#{tabl}
|
186
|
-
#{filt}
|
189
|
+
`#{tabl}`#{filt}
|
187
190
|
group by
|
188
191
|
val
|
189
192
|
order by #{sort}
|
190
|
-
|
191
|
-
-if(regexp_like(`#{name}`, '^0\\\\d+$'), length(`#{name}`), null) desc,
|
192
|
-
-if(regexp_like(`#{name}`, '^\\\\d'), regexp_instr(`#{name}`, '[^\\\\d]'), null) desc,
|
193
|
+
#{like}
|
193
194
|
`#{name}` is null, `#{name}`
|
195
|
+
#{show ? "limit #{show}" : ""}
|
194
196
|
|
195
|
-
uniq, tots = conn.sql(<<~"").to_a[0]
|
197
|
+
uniq, tots = conn.sql(<<~"".rstrip).to_a[0]
|
196
198
|
select
|
197
199
|
count(distinct(ifnull(`#{name}`,0))),
|
198
200
|
count(ifnull(`#{name}`,0))
|
199
201
|
from
|
200
|
-
`#{tabl}
|
201
|
-
#{filt}
|
202
|
+
`#{tabl}`#{filt}
|
202
203
|
|
203
204
|
display(name, data, show, uniq, tots)
|
204
205
|
end
|
data/bin/slyced
CHANGED
data/slyce.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.executables = `cd bin && git ls-files .`.split("\n")
|
14
14
|
s.add_runtime_dependency "any_ascii", "~> 0.3.2"
|
15
15
|
s.add_runtime_dependency "censive", "~> 1.1.0"
|
16
|
-
s.add_runtime_dependency "duckdb", "~> 0.8.
|
17
|
-
s.add_runtime_dependency "extralite-bundle", "~> 1
|
16
|
+
s.add_runtime_dependency "duckdb", "~> 0.8.1"
|
17
|
+
s.add_runtime_dependency "extralite-bundle", "~> 2.1"
|
18
18
|
s.add_runtime_dependency "mysql2", "~> 0.5"
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: any_ascii
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.8.
|
47
|
+
version: 0.8.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.8.
|
54
|
+
version: 0.8.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: extralite-bundle
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1
|
61
|
+
version: '2.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1
|
68
|
+
version: '2.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mysql2
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.4.
|
118
|
+
rubygems_version: 3.4.16
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Ruby utility to show data statistics for MySQL databases
|