pgcopy
Fast db insert with postgresql binary copy
What it is and what it does
pgcopy is a thin wrapper around PostgreSQL's native binary COPY command, exposed through a simple Python API. It lets you load bulk data into PostgreSQL tables orders of magnitude faster than traditional INSERT statements by leveraging the database's optimized binary protocol. The package handles encoding, type conversion, and schema awareness transparently, supporting a wide range of PostgreSQL data types including arrays, JSON, UUIDs, and timestamps with timezone.
You instantiate a CopyManager with a psycopg2 connection, table name, and column list, then call copy() with an iterable of tuples or dicts. The package converts your Python data to PostgreSQL's binary format and streams it directly into the table. It's designed for one-shot bulk loads and table replacements rather than streaming or incremental inserts.
Use it for:
- Migrating large datasets into PostgreSQL from CSV, JSON, or in-memory collections.
- Periodic bulk imports of metrics, logs, or sensor data where speed matters more than row-by-row control.
- Replacing entire tables atomically with fresh data from an external source.
- Loading test fixtures or seed data during application initialization or CI/CD pipelines.
- Batch ETL workflows where you stage data in Python and need to land it in Postgres quickly.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pgcopy wraps PostgreSQL's binary COPY protocol to load data into tables much faster than row-by-row inserts, using psycopg2 as the connection layer.
Yes, if you need to load bulk data into PostgreSQL and speed is a priority. The package is stable, has no known vulnerabilities, and carries minimal dependencies. The main caveat is aging maintenance—last release was 264 days ago—so if you hit a bug or need support for a new PostgreSQL feature, responsiveness is uncertain. For one-off bulk loads or established workflows, it's a solid choice; for mission-critical systems requiring active support, verify the maintainer's current availability first.
Install
pgcopy on PyPI
pip
pip install pgcopyuv
uv add pgcopypoetry
poetry add pgcopyInstalling pgcopy
Before you install
Low install friction with a pure-Python wheel and only two runtime dependencies (psycopg2 and pytz). Maintenance status is aging—last release was 264 days ago—but the package is marked Production/Stable and carries no known vulnerabilities.
License in practice
MIT license is permissive; you can use, modify, and distribute pgcopy freely in commercial and private projects with minimal restrictions.
Quickstart
from pgcopy import CopyManager
import psycopg2
conn = psycopg2.connect(database='mydb')
mgr = CopyManager(conn, 'my_table', ('col1', 'col2'))
mgr.copy([(1, 'a'), (2, 'b')])
conn.commit()
Requires an active PostgreSQL database and a valid psycopg2 connection; the target table must already exist.
Verify before relying
- Whether the package works with current PostgreSQL versions beyond 9.3 (documentation references 9.3 but classifiers list Python 3.9–3.14).
- Current maintenance status and likelihood of future updates or bug fixes given the 264-day release gap.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — psycopg2, pytz |
| Maintenance | aging — 264 days since the last release |
| First released | |
| Downloads | 239,550/month — #8,919 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pgcopy-1.6.2-py2.py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
django-postgres-copyProvides Django ORM integration for…
permissive · top 5,000 on PyPI
pgpqEncodes PyArrow RecordBatches into PostgreSQL's…
permissive · top 15,000 on PyPI
pysqlsyncSynchronize database schemas and bulk-load data…
permissive · top 15,000 on PyPI
psycopg2-poolManages a pool of reusable PostgreSQL…
copyleft · top 15,000 on PyPI
postgresProvides a lightweight abstraction layer over…
permissive · top 15,000 on PyPI
queriesQueries is a simplified wrapper around psycopg2…
permissive · top 15,000 on PyPI
django-pg-bulk-updateExecutes bulk update and bulk create operations…
permissive · top 15,000 on PyPI
pgdbWraps PostgreSQL connections to return query…
permissive · top 15,000 on PyPI
tsv2pyParses and generates tab-separated values (TSV)…
permissive · top 15,000 on PyPI