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
You can use pgslim in either Interactive Mode or Command-Line Mode.
Interactive Mode (Recommended)
Simply run the tool with no arguments to start an interactive wizard. It will scan your current directory for .sql files, fast-scan the selected file for tables and columns, and provide searchable dropdown menus to make your selection.
pgslim
Alternatively, you can provide a directory path to scan for .sql files:
pgslim /path/to/dumps
Command-Line Mode
For automation or quick usage, provide the input SQL file, the table name, and the column you want to nullify directly as positional arguments or named flags.
# Using positional arguments
pgslim dump_old.sql my_table large_column
# Using named flags
pgslim -i dump_old.sql -t my_table -c large_column -v
This will create a new file named dump_old_slim.sql (unless you specify a custom output with -o).
Arguments
| Positional / Named Flag | Description |
|---|---|
input / -i, --input |
Input SQL dump file (plain text format) |
table / -t, --table |
Name of the table (e.g., users) |
column / -c, --column |
Name of the column to nullify (e.g., attachment) |
| Optional Flag | Description |
|---|---|
-o, --output |
Output SQL dump file (defaults to <input>_slim.sql) |
-v, --verbose |
Enable verbose output to see detailed progress |
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
Metadata
Release files for pgslim 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pgslim-0.2.4.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pgslim-0.2.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 14.7 kB
Release files / pgslim-0.2.4.tar.gz
| Download URL | pgslim-0.2.4.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
181bf3f16360f302c920c424970da9fa6af0105f24275b9b0844d925e497d721
|
|
BLAKE2b-256 checksum How to use checksums |
c3d0832ebc8e0d8a447888c9156063bfef438e9376f2427f28b0660b7e86c079
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / pgslim-0.2.4-py2.py3-none-any.whl
| Download URL | pgslim-0.2.4-py2.py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fb13840ca603983bf5d6560f831366a6684505f16159964ccadee3c4d5bc2699
|
|
BLAKE2b-256 checksum How to use checksums |
3542f28b5003cfef3156c77963eab96943fd883127cb6a3c863b26f095981420
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|