Releases: miichoow/PyPGKit
Releases · miichoow/PyPGKit
v1.0.0
PyPGKit v1.0.0
We're excited to announce the first stable release of PyPGKit - a PostgreSQL database framework for Python using psycopg3 with connection pooling, thread-safety, and repository pattern.
Features
- Connection Pooling - Thread-safe connection pool using psycopg_pool with automatic health checks and idle connection recycling
- Singleton Pattern - Global database instance with Database.init() and Database.get_instance() for easy access throughout your application
- Repository Pattern - Generic BaseRepository[T] class with full CRUD operations (find_by_id, find_all, find_by, create, create_many, update, delete, count, exists)
- Automatic Setup - Automatically create database, user, and initialize schema on first run
- Fork Safety - Compatible with gunicorn and other forking servers with automatic pool reset
- Transaction Support - Context manager for transaction handling with automatic commit/rollback
- Configurable Logging - Built-in logging with multiple formats and optional psycopg log inclusion
- Environment Configuration - Load config from environment variables with PYPGKIT_ prefix
- Full Type Hints - Complete type annotations for better IDE support and type checking
Installation
pip install PyPGKitQuick Start
from pypgkit import Database, DatabaseConfig
# Initialize once at application startup
config = DatabaseConfig(
host="localhost",
port=5432,
database="myapp",
user="myuser",
password="mypassword",
)
Database.init(config=config, schema_path="schemas/init.sql")
# Use anywhere in your application
db = Database.get_instance()
users = db.fetch_all("SELECT * FROM users WHERE active = %s", (True,))Requirements
- Python 3.9, 3.10, 3.11, 3.12, or 3.13
- PostgreSQL 12+
- psycopg 3.x
- psycopg-pool