Simple PostgreSQL connections
Project description
SimplePG
Simple PostgreSQL connections: a wrapper around psycopg2.
Features:
- Thread-safe connection pooling
- Auto-reconnect on connection loss
- Unified interface for execute, executemany, and execute_values
Installation
pip install simplepg
Example
from simplepg import DbConnection
db = DbConnection(
user="postgres",
password="postgres",
host="localhost",
port=5432,
database="postgres",
connect_kwargs={},
pool_min_connections=1,
pool_max_connections=1,
)
db.execute("CREATE TABLE test_table (id SERIAL PRIMARY KEY, name VARCHAR)")
db.execute_values("INSERT INTO test_table (name) VALUES %s", [("test1",), ("test2",)])
records, columns = db.execute("SELECT * FROM test_table")
db.execute("DROP TABLE test_table")
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
simplepg-0.1.5.tar.gz
(7.7 kB
view hashes)