Fast db insert with postgresql binary copy
Project description
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
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
Documentation
See Also
cpgcopy, a Cython implementation, about twice as fast.
Project details
Release history Release notifications | RSS feed
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.5.0.tar.gz
(12.7 kB
view hashes)
Built Distribution
pgcopy-1.5.0-py2.py3-none-any.whl
(12.6 kB
view hashes)
Close
Hashes for pgcopy-1.5.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b0451a4dbbd4c74ed148c2f831df10be2e2368ee0f62115c24f5a2f76ed2528 |
|
MD5 | fe5ad2c3d3d5c071ce01b93ae2442500 |
|
BLAKE2b-256 | 21fbad549deeaedf4932f1cb5d89d9a844105d49d42330f6cd0fb357ac210106 |