sqlconv 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sqlconv +10 -5
  3. data/sqlconv.gemspec +1 -1
  4. metadata +1 -3
  5. data/bin/dude.sql +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9aa1c3943808e8d4a17d7d31a10042b0bac9f650f7a87f470dc15826d63722b5
4
- data.tar.gz: 1ac89760f3959aeb17dde7a0f7b2221cbb4738879a81c3c68ee4eaa82be90d27
3
+ metadata.gz: 75d8adb86fa58ca1988fa029bbd72c08f08bdce1b2d15d0329aa368de92daa3d
4
+ data.tar.gz: b5b86990ec7db00261c0216088fdf5321c13abd650d3011666be6ebbd113b9c2
5
5
  SHA512:
6
- metadata.gz: b26f50074d489402933f0a2192c3b44e471393a626006c2b892f8e9cb019b81288a9565d6cad63ead36f5adb95789068c638cda9dd939bea900cd694d163b97a
7
- data.tar.gz: 2c270f0a241c0a9e2d3ed6d0b2dfe77758192a575bd6d89d24cd62411dd55d9ed5a35110f73e996c5e4be5d07c95b5bba6c14cfddd78bd76cf137b9efe79f943
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] == "-r"
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
- "[-r <plugin1.rb> [-r <plugin2.rb>]...]",
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sqlconv"
5
- s.version = "0.7.1"
5
+ s.version = "0.8.0"
6
6
  s.author = "Steve Shreeve"
7
7
  s.email = "steve.shreeve@gmail.com"
8
8
  s.summary = "Handy utility to massage MySQL dump files"
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.7.1
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
@@ -1,2 +0,0 @@
1
- INSERT INTO `cats` VALUES (4,'1503250\'034279_user',1,'2018-04-16 23:44:03');
2
- INSERT INTO `cats` VALUES (5,'150325\n\n\n0034280_token',0,'2018-04-16 23:44:03');