Skip to main content

A simple tool to reduce PostgreSQL dump size by nullifying large bytea/text columns.

Project description

pgslim 🐘

A simple Python CLI tool to reduce the size of a PostgreSQL dump by nullifying large bytea or text columns.

This is particularly useful when you've accidentally stored large files (like images, PDFs, or JSON responses) in your database and want to create a smaller dump for local development or staging.

Installation

You can install pgslim directly from PyPI (once uploaded):

pip install pgslim

Or from source:

git clone https://github.com/nguyenhuy158/pgslim
cd pgslim
pip install .

Usage

Provide the input SQL file, the table name, and the column you want to nullify.

pgslim dump_old.sql farmlink_disbursement_bank_transaction attachment

This will create a new file named dump_old_slim.sql.

Arguments

Positional Description
input Input SQL dump file (plain text format)
table Name of the table (e.g., users)
column Name of the column to nullify (e.g., attachment)
Optional Flag Description
-o, --output Output SQL dump file (defaults to <input>_slim.sql)

How it works

The tool parses the COPY blocks in a PostgreSQL plain-text dump. It identifies the target table and the index of the specified column. For every row in that COPY block, it replaces the column value with \N (PostgreSQL's representation of NULL).

License

MIT

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

pgslim-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

pgslim-0.1.1-py2.py3-none-any.whl (3.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pgslim-0.1.1.tar.gz.

File metadata

  • Download URL: pgslim-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pgslim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 978525491fb637d5dac52df91fb225cc2024febecb7f9d5ac81278dd1884ddaf
MD5 c60a7ae2c9045c5004808b7433d44382
BLAKE2b-256 571bb8d69f2038628dd0150568a3a67c12dd8ce6a5025f400d56c67f1310b5e9

See more details on using hashes here.

File details

Details for the file pgslim-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pgslim-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pgslim-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a1d2971ff7617e95ee6200aab8b09d1161c8a52f8de0f68c7229ebe1fb64375f
MD5 5ae92d2a28c3a61f1ac9a6f510ffffa6
BLAKE2b-256 afb26d1aa167f276c8fcaa2e270b3ba9dfe6b248633dc5682bebd88a937c4d91

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