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
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
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
Built Distribution
File details
Details for the file pgcopy-1.6.0.tar.gz
.
File metadata
- Download URL: pgcopy-1.6.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0da9235eea4ee9ceb4f52b97523bc89db9a6f8e80f897b49214e814ea13d04b0 |
|
MD5 | bb7940ed821f54f32705c462f7582458 |
|
BLAKE2b-256 | b07da5c833f921b20cdb1e8538e72a6065bcc67bbb270fa7a35e98f2d397ce0c |
File details
Details for the file pgcopy-1.6.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pgcopy-1.6.0-py2.py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fb7fee568f8c98dc4b7803e65dc52dd1d8feccce036e4bef69ab83e6a87ffbc |
|
MD5 | be95c3d645fd753090672888943d04ae |
|
BLAKE2b-256 | 4355b2167b19603ef9242d82074052a6fa16127edaa8e9c1520c795c6f68a45c |