skillfed

pgcopy

Fast db insert with postgresql binary copy

pgcopy v1.6.2 239.6K downloads/30d#8,919 on PyPI
Permissive license MIT AGING released

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 pgcopy

uv

uv add pgcopy

poetry

poetry add pgcopy

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Database

Tags

postgresql bulk insertfast data loading postgresbinary copy postgresqlbulk load postgrespsycopg2 batch insertpostgresql copy protocolhigh-throughput postgres insert
bulk-insertpostgresqletl

More Database packages