intosql 0.1.0 → 0.2.1
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/CHANGELOG.md +8 -0
- data/README.md +10 -0
- data/lib/intosql/models.rb +7 -1
- data/lib/intosql/report.rb +84 -0
- data/lib/intosql/version.rb +1 -1
- data/lib/intosql.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1bd39e307362f1004ebb0c6b2cafe15fd5048483237a1c4d4964bd09b4cea5f
|
|
4
|
+
data.tar.gz: 9b8b6b32ff26c1f73ff8522b766162cd238ae6c8e817c5fb2ee3adae52170d58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58af7ac347d3f456b8c77a05fd1829111303fa3e1bea35b76193fecc2e41b0ad348052dba3a3258d5dcd05c23f329d3ff08e702cca863c855835d42057e2bcbd
|
|
7
|
+
data.tar.gz: 8e85321133271a88a84dc97a3835f8038a551c4f3af6f4050f7094fce8db284be581a84da7e20144dafbcc6bd9b0b956e8656df11bd911caaed0d408a083cb96
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
- The README says a MySQL or MariaDB dump converts to any of the six databases, and its report carries the codes of each target.
|
|
6
|
+
|
|
7
|
+
## 0.2.0
|
|
8
|
+
|
|
9
|
+
- Reports of database dumps: `source`, `tables` and `not_converted`.
|
|
10
|
+
|
|
3
11
|
## 0.1.0
|
|
4
12
|
|
|
5
13
|
- `convert` and `convert_url`, every conversion endpoint (`create`, `create_from_url`, `upload`, `start`, `retrieve`, `list`, `cancel`, `create_case`, `delete`, `wait`), `usage` and `spec`.
|
data/README.md
CHANGED
|
@@ -22,6 +22,16 @@ puts conversion.report[:rows][:converted], conversion.output.url
|
|
|
22
22
|
|
|
23
23
|
The file streams to storage as it is; the output URL downloads the script for ten minutes. Read the conversion again (`intosql.conversions.retrieve(id)`) for a fresh one.
|
|
24
24
|
|
|
25
|
+
A MySQL or MariaDB dump (`.sql`, `.sql.gz`) converts to any of the six databases like any file. `job_report` reads the report with each of its tables:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
conversion = intosql.convert("shop.sql.gz", spec: IntoSQL.spec(dialect: "postgresql"))
|
|
29
|
+
|
|
30
|
+
conversion.job_report.tables.each do |table|
|
|
31
|
+
puts "#{table.name}: #{table.rows} rows"
|
|
32
|
+
end
|
|
33
|
+
```
|
|
34
|
+
|
|
25
35
|
## Convert a file by URL
|
|
26
36
|
|
|
27
37
|
```ruby
|
data/lib/intosql/models.rb
CHANGED
|
@@ -36,7 +36,8 @@ module IntoSQL
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
# A conversion as the API answers it. `spec` and `report` are hashes with symbol keys
|
|
39
|
+
# A conversion as the API answers it. `spec` and `report` are hashes with symbol keys;
|
|
40
|
+
# `job_report` reads `report` as a typed JobReport.
|
|
40
41
|
Conversion = Struct.new(
|
|
41
42
|
:id, :status, :name, :bytes, :spec, :report, :error, :output, :upload,
|
|
42
43
|
:created_at, :started_at, :finished_at, :expires_at,
|
|
@@ -49,6 +50,11 @@ module IntoSQL
|
|
|
49
50
|
fields[:upload] &&= UploadTarget.from_h(fields[:upload])
|
|
50
51
|
new(**fields)
|
|
51
52
|
end
|
|
53
|
+
|
|
54
|
+
# The report as a JobReport, or nil before the conversion ran.
|
|
55
|
+
def job_report
|
|
56
|
+
report && JobReport.from_h(report)
|
|
57
|
+
end
|
|
52
58
|
end
|
|
53
59
|
|
|
54
60
|
# A conversion sent to IntoSQL because it didn't come out right.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module IntoSQL
|
|
4
|
+
# What a database dump defines besides tables. The engine may add kinds; they arrive as plain strings.
|
|
5
|
+
module ObjectKind
|
|
6
|
+
VIEW = "view"
|
|
7
|
+
TRIGGER = "trigger"
|
|
8
|
+
PROCEDURE = "procedure"
|
|
9
|
+
FUNCTION = "function"
|
|
10
|
+
EVENT = "event"
|
|
11
|
+
ALL = [VIEW, TRIGGER, PROCEDURE, FUNCTION, EVENT].freeze
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# A correction the engine made, numbered like a proofreader's mark. `code` is a string.
|
|
15
|
+
Fix = Struct.new(:number, :code, :column, :row, :args, keyword_init: true) do
|
|
16
|
+
extend Model
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Something that stopped the conversion, left a row out or needs a look. `code` is a string.
|
|
20
|
+
Problem = Struct.new(:code, :severity, :column, :row, :args, keyword_init: true) do
|
|
21
|
+
extend Model
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# One column as it was read and as it was written. `fixes` holds the numbers of the fixes that touched it.
|
|
25
|
+
ColumnReport = Struct.new(
|
|
26
|
+
:source_name, :name, :sql_type, :kind, :precision, :scale, :max_chars, :nullable, :fixes, :excluded, :as_text,
|
|
27
|
+
keyword_init: true
|
|
28
|
+
) do
|
|
29
|
+
def self.from_h(hash)
|
|
30
|
+
new(**hash.slice(*members), fixes: hash[:fixes] || [])
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Where a database dump comes from: `dialect`, `version`, `producer`, `charset` and `databases`.
|
|
35
|
+
SourceReport = Struct.new(:dialect, :version, :producer, :charset, :databases, keyword_init: true) do
|
|
36
|
+
def self.from_h(hash)
|
|
37
|
+
new(**hash.slice(*members), databases: hash[:databases] || [])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# One table of a database dump, with its own rows, columns, fixes and problems.
|
|
42
|
+
TableReport = Struct.new(:source_name, :name, :schema, :rows, :columns, :fixes, :problems, keyword_init: true) do
|
|
43
|
+
def self.from_h(hash)
|
|
44
|
+
new(
|
|
45
|
+
**hash.slice(*members),
|
|
46
|
+
columns: Reports.list(hash[:columns], ColumnReport),
|
|
47
|
+
fixes: Reports.list(hash[:fixes], Fix),
|
|
48
|
+
problems: Reports.list(hash[:problems], Problem)
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# A view, trigger, routine or event of a dump that the conversion did not carry.
|
|
54
|
+
NotConverted = Struct.new(:kind, :name, keyword_init: true) do
|
|
55
|
+
extend Model
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# What a conversion did. `input`, `rows` and `timings` stay hashes with symbol keys.
|
|
59
|
+
# For a database dump, `source`, `tables` and `not_converted` say what it held; otherwise they are nil and empty.
|
|
60
|
+
JobReport = Struct.new(
|
|
61
|
+
:version, :input, :dialect, :table, :columns, :rows, :fixes, :problems, :timings,
|
|
62
|
+
:source, :tables, :not_converted,
|
|
63
|
+
keyword_init: true
|
|
64
|
+
) do
|
|
65
|
+
def self.from_h(hash)
|
|
66
|
+
new(
|
|
67
|
+
**hash.slice(*members),
|
|
68
|
+
columns: Reports.list(hash[:columns], ColumnReport),
|
|
69
|
+
fixes: Reports.list(hash[:fixes], Fix),
|
|
70
|
+
problems: Reports.list(hash[:problems], Problem),
|
|
71
|
+
source: hash[:source] && SourceReport.from_h(hash[:source]),
|
|
72
|
+
tables: Reports.list(hash[:tables], TableReport),
|
|
73
|
+
not_converted: Reports.list(hash[:not_converted], NotConverted)
|
|
74
|
+
)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Builds the typed lists of a report, empty when the field is missing.
|
|
79
|
+
module Reports
|
|
80
|
+
def self.list(items, type)
|
|
81
|
+
(items || []).map { |item| type.from_h(item) }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
data/lib/intosql/version.rb
CHANGED
data/lib/intosql.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: intosql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- IntoSQL
|
|
@@ -24,6 +24,7 @@ files:
|
|
|
24
24
|
- lib/intosql/conversions.rb
|
|
25
25
|
- lib/intosql/errors.rb
|
|
26
26
|
- lib/intosql/models.rb
|
|
27
|
+
- lib/intosql/report.rb
|
|
27
28
|
- lib/intosql/source.rb
|
|
28
29
|
- lib/intosql/spec.rb
|
|
29
30
|
- lib/intosql/transport.rb
|