Skip to main content

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:

# install pipx via your favorite package manager
pipx install sqldump2json

For crappy distros like Ubuntu you need to do more steps:

  • Install pyenv or asdf-vm.
  • Install latest python version and make it global via pyenv or asdf-vm.
  • 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
...

Hex strings are converted to base64:

sqldump2json -i testdata/dump.sql | tail -4 | head -1 | jq -r '.values[4]' | base64 -d > image.png

Also supports basic arifmetic expressions:

$ echo 'insert into test (result) values (-2 + 2 * 2);' | sqldump2json
{"table_name": "test", "values": {"result": 2}}

Project details


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.15.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

sqldump2json-0.1.15-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file sqldump2json-0.1.15.tar.gz.

File metadata

  • Download URL: sqldump2json-0.1.15.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.7-arch1-1

File hashes

Hashes for sqldump2json-0.1.15.tar.gz
Algorithm Hash digest
SHA256 130a0a7a4ad558b12b0eee3f9583ba3a3ee6fc4aad701744692060fdddc4c2e7
MD5 f622f9dcfe8a949cca596689c3a4ac43
BLAKE2b-256 5a0598a7e0a599531eee6bc7c26962f5512bca5e71b3c1a96c88c8563422287d

See more details on using hashes here.

File details

Details for the file sqldump2json-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: sqldump2json-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.7-arch1-1

File hashes

Hashes for sqldump2json-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 510193abc168a9835c582ecd5ddea3e2f25a1ee354af710f9f19539344dfc190
MD5 f916eb7c148865bfa94d681123336410
BLAKE2b-256 39b14f8673136c20be9735f53ef690f44d7fdae7cab9c404632fb58994e28ab7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page