rosetta-sql 1.0.0__tar.gz

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.
Files changed (48) hide show
  1. rosetta_sql-1.0.0/LICENSE +21 -0
  2. rosetta_sql-1.0.0/PKG-INFO +379 -0
  3. rosetta_sql-1.0.0/README.md +349 -0
  4. rosetta_sql-1.0.0/benchmark/generate_csv_data.py +83 -0
  5. rosetta_sql-1.0.0/benchmark/import_data.py +168 -0
  6. rosetta_sql-1.0.0/pyproject.toml +47 -0
  7. rosetta_sql-1.0.0/rosetta/__init__.py +3 -0
  8. rosetta_sql-1.0.0/rosetta/__main__.py +8 -0
  9. rosetta_sql-1.0.0/rosetta/benchmark.py +1678 -0
  10. rosetta_sql-1.0.0/rosetta/buglist.py +108 -0
  11. rosetta_sql-1.0.0/rosetta/cli/__init__.py +11 -0
  12. rosetta_sql-1.0.0/rosetta/cli/config_cmd.py +243 -0
  13. rosetta_sql-1.0.0/rosetta/cli/exec.py +219 -0
  14. rosetta_sql-1.0.0/rosetta/cli/interactive_cmd.py +124 -0
  15. rosetta_sql-1.0.0/rosetta/cli/list_cmd.py +215 -0
  16. rosetta_sql-1.0.0/rosetta/cli/main.py +617 -0
  17. rosetta_sql-1.0.0/rosetta/cli/output.py +545 -0
  18. rosetta_sql-1.0.0/rosetta/cli/result.py +61 -0
  19. rosetta_sql-1.0.0/rosetta/cli/result_cmd.py +247 -0
  20. rosetta_sql-1.0.0/rosetta/cli/run.py +625 -0
  21. rosetta_sql-1.0.0/rosetta/cli/status.py +161 -0
  22. rosetta_sql-1.0.0/rosetta/comparator.py +205 -0
  23. rosetta_sql-1.0.0/rosetta/config.py +139 -0
  24. rosetta_sql-1.0.0/rosetta/executor.py +403 -0
  25. rosetta_sql-1.0.0/rosetta/flamegraph.py +630 -0
  26. rosetta_sql-1.0.0/rosetta/interactive.py +1790 -0
  27. rosetta_sql-1.0.0/rosetta/models.py +197 -0
  28. rosetta_sql-1.0.0/rosetta/parser.py +308 -0
  29. rosetta_sql-1.0.0/rosetta/reporter/__init__.py +1 -0
  30. rosetta_sql-1.0.0/rosetta/reporter/bench_html.py +1457 -0
  31. rosetta_sql-1.0.0/rosetta/reporter/bench_text.py +162 -0
  32. rosetta_sql-1.0.0/rosetta/reporter/history.py +1686 -0
  33. rosetta_sql-1.0.0/rosetta/reporter/html.py +644 -0
  34. rosetta_sql-1.0.0/rosetta/reporter/text.py +110 -0
  35. rosetta_sql-1.0.0/rosetta/runner.py +3089 -0
  36. rosetta_sql-1.0.0/rosetta/ui.py +736 -0
  37. rosetta_sql-1.0.0/rosetta/whitelist.py +161 -0
  38. rosetta_sql-1.0.0/rosetta_sql.egg-info/PKG-INFO +379 -0
  39. rosetta_sql-1.0.0/rosetta_sql.egg-info/SOURCES.txt +46 -0
  40. rosetta_sql-1.0.0/rosetta_sql.egg-info/dependency_links.txt +1 -0
  41. rosetta_sql-1.0.0/rosetta_sql.egg-info/entry_points.txt +2 -0
  42. rosetta_sql-1.0.0/rosetta_sql.egg-info/requires.txt +6 -0
  43. rosetta_sql-1.0.0/rosetta_sql.egg-info/top_level.txt +8 -0
  44. rosetta_sql-1.0.0/setup.cfg +4 -0
  45. rosetta_sql-1.0.0/setup.py +5 -0
  46. rosetta_sql-1.0.0/skills/rosetta/scripts/install_rosetta.py +469 -0
  47. rosetta_sql-1.0.0/skills/rosetta/scripts/rosetta_wrapper.py +377 -0
  48. rosetta_sql-1.0.0/tests/test_cli.py +749 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yangshijie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,379 @@
1
+ Metadata-Version: 2.1
2
+ Name: rosetta-sql
3
+ Version: 1.0.0
4
+ Summary: Cross-DBMS SQL behavioral consistency verification tool
5
+ Author: yangshijie
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/sjyango/rosetta
8
+ Project-URL: Repository, https://github.com/sjyango/rosetta
9
+ Project-URL: Issues, https://github.com/sjyango/rosetta/issues
10
+ Keywords: sql,database,consistency,testing,benchmark,mysql,tdsql,tidb,oceanbase
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Database
21
+ Classifier: Topic :: Software Development :: Testing
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: pymysql>=1.0
26
+ Requires-Dist: rich>=13.0
27
+ Requires-Dist: prompt_toolkit>=3.0.52
28
+ Provides-Extra: mysql-connector
29
+ Requires-Dist: mysql-connector-python>=8.0; extra == "mysql-connector"
30
+
31
+ # Rosetta
32
+ Cross-DBMS SQL testing & benchmarking toolkit.
33
+
34
+ Rosetta executes SQL against multiple databases (TDSQL, MySQL, TiDB, OceanBase, etc.), compares behavioral consistency via MTR-style `.test` files, benchmarks query performance, and provides an interactive SQL playground — all with visual reports.
35
+
36
+ ## Requirements
37
+ - Python >= 3.8
38
+ - PyMySQL >= 1.0
39
+ - Rich >= 13.0
40
+ - prompt_toolkit >= 3.0.52
41
+
42
+ ## Installation
43
+
44
+ ### One-line Install (Recommended)
45
+ ```bash
46
+ curl -fsSL https://raw.githubusercontent.com/sjyango/rosetta/main/install.sh | bash
47
+ ```
48
+
49
+ This script will:
50
+ - Clone the repository to `~/.rosetta`
51
+ - Create a Python virtual environment
52
+ - Install all dependencies
53
+ - Add `rosetta` to your PATH
54
+
55
+ **Options**:
56
+ ```bash
57
+ # Install to custom directory
58
+ curl -fsSL https://raw.githubusercontent.com/sjyango/rosetta/main/install.sh | bash -s -- -d /opt/rosetta
59
+
60
+ # Install specific branch
61
+ curl -fsSL https://raw.githubusercontent.com/sjyango/rosetta/main/install.sh | bash -s -- -b release-1.0.0
62
+ ```
63
+
64
+ ### Manual Install
65
+ ```bash
66
+ git clone https://github.com/sjyango/rosetta.git
67
+ cd rosetta
68
+ pip install -e .
69
+ ```
70
+
71
+ ### Single File (.pyz)
72
+ ```bash
73
+ ./build.sh # Output: dist/rosetta.pyz
74
+ pip install pymysql "rich>=13.0" "prompt_toolkit>=3.0.52"
75
+ python3 rosetta.pyz --help
76
+ ```
77
+
78
+ ## Uninstall
79
+ ```bash
80
+ curl -fsSL https://raw.githubusercontent.com/sjyango/rosetta/main/uninstall.sh | bash
81
+ ```
82
+
83
+ ## Quick Start
84
+ ```bash
85
+ # 1. Generate config file
86
+ rosetta config init
87
+
88
+ # 2. Edit DB connection info
89
+ vim dbms_config.json
90
+
91
+ # 3. Check DB connectivity
92
+ rosetta status
93
+
94
+ # 4. Execute SQL across databases
95
+ rosetta exec --dbms tdsql,mysql --sql "SELECT VERSION()"
96
+
97
+ # 5. Run MTR consistency test
98
+ rosetta mtr --dbms tdsql,mysql -t test.test
99
+
100
+ # 6. Run performance benchmark
101
+ rosetta bench --dbms tdsql,mysql --file bench.json
102
+
103
+ # 7. Browse historical results
104
+ rosetta result list
105
+
106
+ # 8. Interactive mode (REPL)
107
+ rosetta i
108
+ ```
109
+
110
+ ## Usage
111
+ ```bash
112
+ rosetta <command> [options]
113
+ ```
114
+
115
+ ### Global Options
116
+ All commands support these flags (can appear before or after the subcommand):
117
+
118
+ | Argument | Default | Description |
119
+ |----------|---------|-------------|
120
+ | `-j / --json` | `False` | JSON output (AI Agent friendly) |
121
+ | `-c / --config` | `dbms_config.json` | DBMS config file path |
122
+ | `-v / --verbose` | `False` | Enable verbose/debug logging |
123
+
124
+ ### Commands
125
+
126
+ ---
127
+
128
+ #### `status` — Check DB Connection Status
129
+ Check connectivity and version for all enabled databases in config.
130
+
131
+ ```bash
132
+ rosetta status
133
+ rosetta status -j
134
+ rosetta status --timeout 10
135
+ ```
136
+
137
+ | Argument | Default | Description |
138
+ |----------|---------|-------------|
139
+ | `--timeout` | `5` | Connection timeout in seconds |
140
+
141
+ ---
142
+
143
+ #### `exec` — Execute SQL (Playground)
144
+ Execute SQL statements across databases and compare results side-by-side.
145
+
146
+ ```bash
147
+ # Execute single SQL
148
+ rosetta exec --dbms tdsql,mysql --sql "SELECT VERSION()"
149
+
150
+ # Execute SQL from file
151
+ rosetta exec --dbms tdsql,mysql --file queries.sql
152
+
153
+ # Execute on a specific database
154
+ rosetta exec --dbms mysql -d mydb --sql "SHOW TABLES"
155
+ ```
156
+
157
+ | Argument | Required | Default | Description |
158
+ |----------|----------|---------|-------------|
159
+ | `--sql` | one of `--sql` / `--file` | — | SQL statement to execute |
160
+ | `--file` | one of `--sql` / `--file` | — | File containing SQL statements |
161
+ | `--dbms` | ❌ | all enabled | DBMS targets (comma-separated) |
162
+ | `-d / --database` | ❌ | none | Database name (omit to connect without `USE`) |
163
+
164
+ ---
165
+
166
+ #### `mtr` — MTR Consistency Test
167
+ Execute `.test` files and compare SQL execution results across databases. Generates HTML diff reports.
168
+
169
+ ```bash
170
+ # Basic MTR test
171
+ rosetta mtr --dbms tdsql,mysql -t test.test
172
+
173
+ # With baseline comparison
174
+ rosetta mtr --dbms tdsql,mysql --baseline tdsql -t test.test
175
+
176
+ # Parse only (no execution)
177
+ rosetta mtr --dbms tdsql,mysql --parse-only -t test.test
178
+
179
+ # Serve HTML report after test
180
+ rosetta mtr --dbms tdsql,mysql --serve -t test.test
181
+ ```
182
+
183
+ | Argument | Required | Default | Description |
184
+ |----------|----------|---------|-------------|
185
+ | `-t / --test` | ✅ | — | Path to `.test` file |
186
+ | `--dbms` | ✅ | — | DBMS targets (comma-separated) |
187
+ | `-b / --baseline` | ❌ | `tdsql` | Baseline DBMS for diff comparison |
188
+ | `-d / --database` | ❌ | `rosetta_mtr_test` | Test database name |
189
+ | `-o / --output-dir` | ❌ | `results` | Report output directory |
190
+ | `-f / --output-format` | ❌ | `all` | Report format: `text`, `html`, `all` |
191
+ | `--parse-only` | ❌ | `False` | Only parse `.test` file, no execution |
192
+ | `--diff-only` | ❌ | `False` | Re-generate reports from existing `.result` files |
193
+ | `-s / --serve` | ❌ | `False` | Start HTTP server to view reports |
194
+ | `-p / --port` | ❌ | `19527` | HTTP server port |
195
+
196
+ ---
197
+
198
+ #### `bench` — Performance Benchmark
199
+ Compare query performance across databases with custom workloads. Supports serial and concurrent modes.
200
+
201
+ ```bash
202
+ # Serial benchmark
203
+ rosetta bench --dbms tdsql,mysql --mode SERIAL --iterations 10 --file bench.json
204
+
205
+ # Concurrent benchmark (8 threads, 60s)
206
+ rosetta bench --dbms tdsql,mysql \
207
+ --mode CONCURRENT --concurrency 8 --duration 60 --file bench.json
208
+
209
+ # Skip setup (reuse tables from previous run)
210
+ rosetta bench --dbms tdsql,mysql --skip-setup --file bench.json
211
+
212
+ # Disable flame graph capture
213
+ rosetta bench --dbms tdsql,mysql --no-profile --file bench.json
214
+ ```
215
+
216
+ | Argument | Required | Default | Description |
217
+ |----------|----------|---------|-------------|
218
+ | `--dbms` | ✅ | — | DBMS targets (comma-separated) |
219
+ | `--file` | ✅ | — | Benchmark definition file (`.json` / `.sql`) |
220
+ | `--mode` | ❌ | `SERIAL` | Execution mode: `SERIAL` or `CONCURRENT` |
221
+ | `-d / --database` | ❌ | `rosetta_bench_test` | Benchmark database name |
222
+ | `-o / --output-dir` | ❌ | `results` | Report output directory |
223
+ | `-f / --output-format` | ❌ | `all` | Report format: `text`, `html`, `all` |
224
+
225
+ **Serial mode** (`--mode SERIAL`):
226
+
227
+ | Argument | Default | Description |
228
+ |----------|---------|-------------|
229
+ | `--iterations` | `1` | Iterations per query |
230
+ | `--warmup` | `0` | Warmup iterations |
231
+
232
+ **Concurrent mode** (`--mode CONCURRENT`):
233
+
234
+ | Argument | Default | Description |
235
+ |----------|---------|-------------|
236
+ | `--concurrency` | `10` | Number of concurrent threads |
237
+ | `--duration` | `30` | Duration in seconds |
238
+ | `--warmup` | `0` | Warmup duration in seconds |
239
+ | `--ramp-up` | `0` | Ramp-up seconds for threads |
240
+
241
+ **Common options**:
242
+
243
+ | Argument | Default | Description |
244
+ |----------|---------|-------------|
245
+ | `--query-timeout` | `5` | Query timeout in seconds (0 = disabled) |
246
+ | `--bench-filter` | — | Run only queries matching these names (comma-separated) |
247
+ | `--repeat` | `1` | Number of benchmark rounds |
248
+ | `--skip-setup` | `False` | Skip setup phase (reuse existing tables) |
249
+ | `--skip-teardown` | `False` | Skip teardown (keep tables for next run) |
250
+ | `--no-parallel-dbms` | `False` | Run DBMS targets sequentially |
251
+ | `--no-profile` | `False` | Disable flame-graph capture |
252
+ | `--perf-freq` | `99` | perf sampling frequency in Hz |
253
+
254
+ ---
255
+
256
+ #### `config` — Manage Configuration
257
+ View, validate, or generate DBMS configuration files.
258
+
259
+ ```bash
260
+ # Generate sample config
261
+ rosetta config init
262
+
263
+ # Generate to custom path
264
+ rosetta config init --output my_config.json
265
+
266
+ # Show current config
267
+ rosetta config show
268
+
269
+ # Validate config (check JSON + connectivity)
270
+ rosetta config validate
271
+ ```
272
+
273
+ | Action | Description |
274
+ |--------|-------------|
275
+ | `init` | Generate a sample `dbms_config.sample.json` |
276
+ | `show` | Display current config details |
277
+ | `validate` | Validate JSON structure and test connectivity |
278
+
279
+ ---
280
+
281
+ #### `result` — Browse Historical Results
282
+ List, inspect, and navigate past MTR and benchmark runs.
283
+
284
+ ```bash
285
+ # List runs (default: 20 per page)
286
+ rosetta result list
287
+
288
+ # Pagination
289
+ rosetta result list -n 10 -p 2
290
+
291
+ # Filter by type
292
+ rosetta result list --type bench
293
+ rosetta result list --type mtr
294
+
295
+ # Show details of latest run
296
+ rosetta result show
297
+
298
+ # Show a specific run (prefix match supported)
299
+ rosetta result show bench_json_mv_select_20260331
300
+
301
+ # JSON output
302
+ rosetta result show -j
303
+ ```
304
+
305
+ **`result list` options**:
306
+
307
+ | Argument | Default | Description |
308
+ |----------|---------|-------------|
309
+ | `-n / --limit` | `20` | Rows per page |
310
+ | `-p / --page` | `1` | Page number |
311
+ | `--type` | `all` | Filter: `all`, `mtr`, `bench` |
312
+ | `-o / --output-dir` | `results` | Results directory |
313
+
314
+ **`result show` options**:
315
+
316
+ | Argument | Default | Description |
317
+ |----------|---------|-------------|
318
+ | `run_id` | latest | Run ID or prefix (optional) |
319
+ | `-o / --output-dir` | `results` | Results directory |
320
+
321
+ ---
322
+
323
+ #### `i` / `repl` / `interactive` — Interactive REPL
324
+ Launch an interactive session for ad-hoc SQL execution, MTR tests, and benchmarks.
325
+
326
+ ```bash
327
+ rosetta i
328
+ rosetta i --dbms tdsql,mysql
329
+ rosetta i --serve
330
+ ```
331
+
332
+ | Argument | Default | Description |
333
+ |----------|---------|-------------|
334
+ | `--dbms` | all enabled | DBMS targets (comma-separated) |
335
+ | `-d / --database` | `cross_dbms_test_db` | Test database name |
336
+ | `-o / --output-dir` | `results` | Report output directory |
337
+ | `-s / --serve` | `False` | Start HTTP server for reports |
338
+ | `-p / --port` | `19527` | HTTP server port |
339
+
340
+ ---
341
+
342
+ ## Configuration
343
+ Sample `dbms_config.json`:
344
+ ```json
345
+ {
346
+ "databases": [
347
+ {
348
+ "name": "tdsql",
349
+ "host": "127.0.0.1",
350
+ "port": 3306,
351
+ "user": "root",
352
+ "password": "",
353
+ "driver": "pymysql",
354
+ "enabled": true
355
+ }
356
+ ]
357
+ }
358
+ ```
359
+
360
+ ## Output Files
361
+ | File | Description |
362
+ |------|-------------|
363
+ | `<test_name>.html` | Interactive HTML report with side-by-side diff |
364
+ | `<test_name>.report.txt` | Text summary report |
365
+ | `bench_result.json` | Benchmark raw data (JSON) |
366
+ | `index.html` | History page of all test runs |
367
+ | `whitelist.json` | Persisted whitelist for acceptable diffs |
368
+ | `buglist.json` | Tracked known bugs from diff results |
369
+
370
+ ## Testing
371
+ ```bash
372
+ python -m pytest tests/test_cli.py -v
373
+ ```
374
+
375
+ ## Getting Help
376
+ ```bash
377
+ rosetta --help
378
+ rosetta <command> --help
379
+ ```