Metadata-Version: 2.4
Name: pgslim
Version: 0.1.2
Summary: A simple tool to reduce PostgreSQL dump size by nullifying large bytea/text columns.
Author-email: Huy Nguyen <huy.ntq02@gmail.com>
License: MIT
Keywords: bytea,dump,postgres,size,slim,sql
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown

# 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):

```bash
pip install pgslim
```

Or from source:

```bash
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.

```bash
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
