Skip to content

pg_summary

ci/cd Documentation Status PyPI Latest Release PyPI Downloads Python Version Support

Create a summary of unique values for each column in a Postgres table or view and summarize results in an Excel workbook.

Output

Installation

You can install pg_summary via pip from PyPI:

pip install pg-summary

There is also a Docker image available on the GitHub Container Registry:

docker pull ghcr.io/geocoug/pg-summary:latest

Usage

The following example demonstrates how to use pg_summary to summarize a Postgres table. By default, the output is an Excel file with one sheet. Each column in the sheet will summarize a column in the Postgres table with the unique values, number of unique values, number of null values, data type, and the column name.

Each of the examples below will produce the exact same output.

Python

from pg_summary import PgSummary

PgSummary(
    host="localhost",
    port=5432,
    database="mydb",
    user="myuser",
    table_or_view="mytable",
    schema="staging",
).summarize()

Command Line

 pg_summary -v localhost -u myuser -d mydb -t mytable -s staging

Docker

docker run --rm -v $(pwd):/data ghcr.io/geocoug/pg-summary:latest -v localhost -u myuser -d mydb -t mytable -s staging