Skip to main content

Fast db insert with postgresql binary copy

Project description

https://github.com/altaurog/pgcopy/actions/workflows/test.yaml/badge.svg?branch=master https://coveralls.io/repos/github/altaurog/pgcopy/badge.svg?branch=master https://img.shields.io/pypi/l/pgcopy.svg https://img.shields.io/pypi/wheel/pgcopy.svg https://img.shields.io/pypi/pyversions/pgcopy.svg

Use pgcopy for fast data loading into PostgreSQL with binary copy.

Features

  • Support for many data types

  • Support for multi-dimensional array types

  • Support for schema and schema search path

  • Support for mixed-case table and column names

  • Transparent string encoding

  • Utility for replacing entire table

Quickstart

from datetime import datetime
from pgcopy import CopyManager
import psycopg2
cols = ('id', 'timestamp', 'location', 'temperature')
now = datetime.now()
records = [
        (0, now, 'Jerusalem', 72.2),
        (1, now, 'New York', 75.6),
        (2, now, 'Moscow', 54.3),
    ]
conn = psycopg2.connect(database='weather_db')
mgr = CopyManager(conn, 'measurements_table', cols)
mgr.copy(records)

# don't forget to commit!
conn.commit()

Supported datatypes

pgcopy supports the following PostgreSQL scalar types:

  • bool

  • smallint

  • integer

  • bigint

  • real

  • double precision

  • char

  • varchar

  • text

  • bytea

  • enum types

  • date

  • time

  • timestamp

  • timestamp with time zone

  • numeric

  • json

  • jsonb

  • uuid

  • arrays

  • vector

Documentation

Read the docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgcopy-1.6.2.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgcopy-1.6.2-py2.py3-none-any.whl (13.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pgcopy-1.6.2.tar.gz.

File metadata

  • Download URL: pgcopy-1.6.2.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pgcopy-1.6.2.tar.gz
Algorithm Hash digest
SHA256 07192bcbfb8655c516cbd070e849c4888b981343de6b385b477ff79d5b8ec914
MD5 e5e00bfb02cec359062cf4747307a40b
BLAKE2b-256 2ed6e88e317a58a981c5f3a06c5d440eb1ae1c20ddbdf1076963ce8221801661

See more details on using hashes here.

File details

Details for the file pgcopy-1.6.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pgcopy-1.6.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pgcopy-1.6.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8ed6dbb54d0e0daa7edd5a0646ec4460191a8c41b434b49c377ff32031e259de
MD5 5c01f4c31c91272181cb297927187be8
BLAKE2b-256 a750af19f2e187c612a7a9db9ffba080d1337d3f260d7c783766214cc9349990

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page