sqlconv 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sqlconv +9 -4
- data/sqlconv.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0bf4b12a25f67b6ce9096183f72b382761003af3ae2c8381ad030e797e9485
|
4
|
+
data.tar.gz: 71f4f416585e7b63e4022b18da68913790a90a975bd5ed862a7637804335ef15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7504113188e39febf08d952c3498d555fc1fe46fa36db1dab06ef5dbf3fb1b0f678c7214c354d96efea8b58a6d0ab1c1e502cccbeb13d574dc8b9f061bbc12
|
7
|
+
data.tar.gz: b0a4fc4f97c3b40432e2dd014a3f1133b7609b8ce8a220878eae2081b9b9ac75c29b4780abc4ce5ee3b9fd5db17e9f74e9fa5935e9ab68d500f0d7ec7232c5e2
|
data/bin/sqlconv
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
STDOUT.sync = true
|
4
4
|
|
5
|
+
def die(str)
|
6
|
+
warn str
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
5
10
|
require 'strscan'
|
6
11
|
|
7
12
|
# parsing helpers
|
@@ -76,7 +81,7 @@ def conv(tab1, map1, tab2, map2, dump)
|
|
76
81
|
# find source table
|
77
82
|
data.string = dump.read # dump.read(5000) # TODO: Add streaming support
|
78
83
|
into = data.scan_for(/insert into (['"`]?)#{tab1}\1 values /io)
|
79
|
-
into or
|
84
|
+
into or die "unable to find insert statements for the '#{tab1}' table"
|
80
85
|
|
81
86
|
# process each line
|
82
87
|
loop do
|
@@ -84,7 +89,7 @@ def conv(tab1, map1, tab2, map2, dump)
|
|
84
89
|
# parse insert statements
|
85
90
|
if data.scan_str("(") or data.scan_str(into + "(")
|
86
91
|
cols = data.scan_while(/('.*?(?<!\\)'|(?>[^',()]+)|,)/, 2)
|
87
|
-
cols.empty? and
|
92
|
+
cols.empty? and die "bad sql parse: '#{line}'"
|
88
93
|
data.scan(/\)[;,]\s*/)
|
89
94
|
else
|
90
95
|
break
|
@@ -166,11 +171,11 @@ if ARGV.size > 0 and !File.exists?(ARGV.first)
|
|
166
171
|
tab1 = nil if $0.size == 0 # no match, show usage
|
167
172
|
end
|
168
173
|
|
169
|
-
tab1 or
|
174
|
+
tab1 or die [
|
170
175
|
"Usage: #{File.basename $0}",
|
171
176
|
"<src_table>(:[sel1,sel2,...])",
|
172
177
|
"[dst_table][:][col1,col2,...] file"
|
173
|
-
] * ' '
|
178
|
+
] * ' '
|
174
179
|
|
175
180
|
conv tab1, map1, tab2 || tab1, map2, ARGF
|
176
181
|
|
data/sqlconv.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlconv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Allows mapping columns from a source to a destination table
|
14
14
|
email: steve.shreeve@gmail.com
|