Parse SQL Dumps to JSON Objects
Project description
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:
# i recommend use pipx instead pip
pipx install sqldump2json
Insert statements are converted to JSON objects on each new line:
$ 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"]}
...
Use jq to process JSON (sort, filter and etc):
$ ./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
...
Also supports basic arifmetic expressions:
$ echo 'insert into test (result) values (-2 + 2 * 2);' | sqldump2json
{"table_name": "test", "values": {"result": 2}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqldump2json-0.1.2.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for sqldump2json-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ff25507890d96e0ba861c1789d38044f821300c798a922142d0b1281bb25420 |
|
MD5 | 3ca6478742bd1a32e6e4586ae33fe0b2 |
|
BLAKE2b-256 | 52a634b5ef17fce6802b80f5a7b511e1671a41c307ea2725b69a02cf52576af5 |