Metadata-Version: 2.1
Name: sqldump2json
Version: 0.1.1
Summary: Parse SQL Dumps to JSON Objects
Home-page: https://github.com/s3rgeym/sqldump2json
License: Free for Personal Use Only
Author: Sergey M
Requires-Python: >=3.11,<4.0
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Project-URL: Repository, https://github.com/s3rgeym/sqldump2json
Description-Content-Type: text/markdown

# README

Parse SQL Dumps to JSON Objects. Tool for Administrators, Data Scientists and Hackers. The dump is not read entirely into RAM, so this utility can be used to process very huge files.

Supported DBMS: MySQL, SQL Server, PotsgreSQL and other

Installation:

```bash
# i recommend use pipx instead pip
pipx install sqldump2json
```

Insert statements are converted to JSON objects on each new line:

```bash
$ sqldump2json -i testdata/dump.sql
{"table_name": "actor", "values": [1, "PENELOPE", "GUINESS", "2006-02-15 04:34:33"]}
{"table_name": "actor", "values": [2, "NICK", "WAHLBERG", "2006-02-15 04:34:33"]}
{"table_name": "actor", "values": [3, "ED", "CHASE", "2006-02-15 04:34:33"]}
...

# as bonus supports basic arifmetic expressions
$ echo 'insert into test (id, result) values (42, -2 + 2 * 2);' | sqldump2json
{"table_name": "test", "values": {"id": 42, "result": 2}}
```

Use [jq](https://github.com/jqlang/jq) to process JSON (sort, filter and etc):

```bash
$ ./sqldump2json -i testdata/dump.sql | jq -r 'select(.table_name == "actor").values | @tsv'
1       PENELOPE        GUINESS 2006-02-15 04:34:33
2       NICK    WAHLBERG        2006-02-15 04:34:33
3       ED      CHASE   2006-02-15 04:34:33
...
```

