A Python testing library that provides seamless integration between PGlite and Python test suites. Get the full power of PostgreSQL in your tests without the overhead of a full PostgreSQL installation. 🎯 Why py-pglite? ⚡ Blazing Fast : In-memory PostgreSQL for ultra-quick test runs : In-memory PostgreSQL for ultra-quick test runs 🛠️ Effortless Setup : No PostgreSQL install needed—just Node.js(I know)! : No PostgreSQL install needed—just Node.js(I know)! 🐍 Pythonic : Native support for SQLAlchemy & SQLModel in your tests : Native support for SQLAlchemy & SQLModel in your tests 🧊 Fully Isolated : Every test module gets its own fresh database : Every test module gets its own fresh database 🦾 100% Compatible : True PostgreSQL features via PGlite : True PostgreSQL features via PGlite 🧩 Pytest Plug-and-Play: Ready-to-use fixtures for instant productivity 📦 Installation Basic Installation pip install py-pglite With Optional Dependencies # For SQLModel support pip install " py-pglite[sqlmodel] " # For FastAPI integration pip install " py-pglite[fastapi] " # For development pip install " py-pglite[dev] " Requirements Python : 3.10+ : 3.10+ Node.js : 18+ (for PGlite) : 18+ (for PGlite) SQLAlchemy: 2.0+ The library automatically manages PGlite npm dependencies. 🚀 Quick Start Basic Usage with Pytest import pytest from sqlmodel import Session , SQLModel , Field , select from py_pglite import pglite_session # Your models class User ( SQLModel , table = True ): id : int | None = Field ( default = None , primary_key = True ) name : str email : str # Test with automatic PGlite management def test_user_creation ( pglite_session : Session ): user = User ( name = "Alice" , email = "alice@example.com" ) pglite_session . add ( user ) pglite_session . commit () # Query back users = pglite_session . exec ( select ( User )). all () assert len ( users ) == 1 assert users [ 0 ]. name == "Alice" Manual Management from py_pglite import PGliteManager , PGliteConfig # Custom configuration config ...
First seen: 2025-06-06 02:05
Last seen: 2025-06-06 16:07