Hasty Briefsbeta

Bilingual

Test Postgres in Python Like SQLite

a year ago
  • #Python
  • #PostgreSQL
  • #Testing
  • Python testing library integrating PGlite with Python test suites for PostgreSQL functionality without full installation.
  • Features include blazing fast in-memory PostgreSQL, effortless setup with Node.js, Pythonic support for SQLAlchemy & SQLModel, fully isolated test databases, and 100% PostgreSQL compatibility.
  • Easy installation via pip with optional support for SQLModel, FastAPI, and development dependencies.
  • Requires Python 3.10+, Node.js 18+, and SQLAlchemy 2.0+.
  • Automatically manages PGlite npm dependencies.
  • Provides pytest fixtures like pglite_engine, pglite_session, and pglite_manager for seamless testing.
  • Includes utilities for database cleanup, schema operations, and table statistics.
  • Supports FastAPI testing by overriding database dependencies.
  • Encourages contributions with a detailed contributing guide and Apache 2.0 License.
  • Best practices include using multiple sessions with the same engine and leveraging utility functions for efficient operations.