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:

# 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
...

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqldump2json-0.1.12-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqldump2json-0.1.12.tar.gz
  • Upload date:
  • Size: 7.6 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.12.tar.gz
Algorithm Hash digest
SHA256 585aa2bc2717339e435d589a0d1f711efdac13342272ee1d76c25c54674f8726
MD5 976739d8ed3940410bdfa0f34cb1ee2b
BLAKE2b-256 07b7cb431c0b8fae5ae5773d22c0afca0723b1744cb3541cb6646a9c06d45e63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqldump2json-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 f1b971775cbc5ee353f8d74c458c5cf733dc2e7d4a55d9eaed203ec9d43bf8a3
MD5 12ef38a4535312f4eb340a591110b246
BLAKE2b-256 8292c91a043e9483516f9f016675cd137406b0426c80aa3cb0a32cd36ebd9998

See more details on using hashes here.

Supported by

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