sqlconv 0.7.1 → 0.8.0
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 +4 -4
- data/bin/sqlconv +10 -5
- data/sqlconv.gemspec +1 -1
- metadata +1 -3
- data/bin/dude.sql +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d8adb86fa58ca1988fa029bbd72c08f08bdce1b2d15d0329aa368de92daa3d
|
4
|
+
data.tar.gz: b5b86990ec7db00261c0216088fdf5321c13abd650d3011666be6ebbd113b9c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c5bb521f9f461a9518c1d5a83eb5d2a1650bf597968531024ae82a197466244bf5d6ec6af8d864eba793e8d932bcee943e53cba8e274acdeb46c78029ded43
|
7
|
+
data.tar.gz: 4144482af48a139dd5507403cd698bcc09bdbbf84d97223642d1bd5ce1c596bfa5e9b2524a9f4734f36d222eb7e4b1096e9d5d2b3109fb401f4dbf8ff976ed2d
|
data/bin/sqlconv
CHANGED
@@ -62,7 +62,7 @@ def grok(want)
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# convert the insert statements
|
65
|
-
def conv(tab1, map1, tab2, map2, dump)
|
65
|
+
def conv(tab1, map1, tab2, map2, repl, dump)
|
66
66
|
data = StringScanner.new("")
|
67
67
|
need = grok(map1)
|
68
68
|
cols = nil
|
@@ -73,7 +73,7 @@ def conv(tab1, map1, tab2, map2, dump)
|
|
73
73
|
|
74
74
|
# statement prefix
|
75
75
|
pref = [
|
76
|
-
"insert into #{tab2 || tab1}",
|
76
|
+
"#{repl ? 'replace' : 'insert'} into #{tab2 || tab1}",
|
77
77
|
(" (#{map2})" if map2),
|
78
78
|
" values (",
|
79
79
|
].compact.join
|
@@ -162,7 +162,7 @@ end
|
|
162
162
|
|
163
163
|
argv = -1
|
164
164
|
ARGV.size.times do
|
165
|
-
if ARGV[argv += 1] == "-
|
165
|
+
if ARGV[argv += 1] == "-p"
|
166
166
|
begin
|
167
167
|
require plugin = ARGV[argv += 1]
|
168
168
|
rescue LoadError
|
@@ -172,6 +172,10 @@ ARGV.size.times do
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
+
if ARGV.delete "-r"
|
176
|
+
repl = true
|
177
|
+
end
|
178
|
+
|
175
179
|
if ARGV.shift =~ /^([a-z][-\w]*):?(.+)?$/
|
176
180
|
tab1 = $1
|
177
181
|
map1 = $2
|
@@ -187,12 +191,13 @@ end
|
|
187
191
|
|
188
192
|
tab1 or die [
|
189
193
|
"Usage: #{File.basename $0}",
|
190
|
-
"[-
|
194
|
+
"[-p <plugin1.rb> [-p <plugin2.rb>]...]",
|
195
|
+
"[-r] (to use 'replace into' instead of 'insert into')",
|
191
196
|
"<src_table>(:[sel1,sel2,...])",
|
192
197
|
"[dst_table][:][col1,col2,...] file"
|
193
198
|
] * ' '
|
194
199
|
|
195
|
-
conv tab1, map1, tab2 || tab1, map2, ARGF
|
200
|
+
conv tab1, map1, tab2 || tab1, map2, repl, ARGF
|
196
201
|
|
197
202
|
__END__
|
198
203
|
|
data/sqlconv.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlconv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
@@ -13,7 +13,6 @@ dependencies: []
|
|
13
13
|
description: Allows mapping columns from a source to a destination table
|
14
14
|
email: steve.shreeve@gmail.com
|
15
15
|
executables:
|
16
|
-
- dude.sql
|
17
16
|
- sqlconv
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
@@ -22,7 +21,6 @@ files:
|
|
22
21
|
- Gemfile
|
23
22
|
- LICENSE
|
24
23
|
- README.md
|
25
|
-
- bin/dude.sql
|
26
24
|
- bin/sqlconv
|
27
25
|
- sqlconv.gemspec
|
28
26
|
homepage: https://github.com/shreeve/sqlconv
|
data/bin/dude.sql
DELETED