$npx skillfedfor your agent

pytest-postgresql

Postgresql fixtures and fixture factories for Pytest.

Worth itPyPI Python ModulesReleased May 20266.6M downloads / mocopyleft licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_postgresql-8.1.0-py3-none-any.whl
v8.1.0 · released 2026-05-15 · Python >=3.10 · 5 runtime deps: pytest, port-for, mirakuru, packaging, psycopg

Yes. The plugin is actively maintained, has no known vulnerabilities, and solves a common testing problem with low install friction. Use it if you need to test code that interacts with PostgreSQL and want automated database lifecycle management. The copyleft license does not restrict your application code, only derivative works of the plugin itself.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires PostgreSQL >= 14 to be installed on the system; the plugin manages the process but does not bundle PostgreSQL itself.
  • Low install friction with a pure-Python wheel.
  • Active maintenance (last commit 2026-08-14) and stable production status.

License · maintenance · safety

copyleft license (copyleft) — Licensed under LGPLv3+, a copyleft license. Derivative works and modifications must be distributed under compatible terms; using the plugin in a project does not impose copyleft on your own code.

last release 2026-05-15 (91 days) · last repo commit 2026-08-14 · 526 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,639,491 downloads/mo, #1,876 on PyPI

Verify before relying

pip install pytest-postgresql psycopg

import pytest
from pytest_postgresql import factories

postgresql_proc = factories.postgresql_proc()
postgresql = factories.postgresql('postgresql_proc')

def test_example(postgresql):
    with postgresql.cursor() as cur:
        cur.execute("CREATE TABLE test (id serial PRIMARY KEY);")
        postgresql.commit()
  • Whether the plugin works with PostgreSQL versions between 14 and the current release date (2026-08-14).
  • Performance characteristics when chaining multiple fixture layers or pre-populating large schemas.
Same gist for agents: .md · .json

What it is and what it does

pytest-postgresql is a pytest plugin that automates PostgreSQL database setup and teardown for tests. It provides fixtures that either start a PostgreSQL instance on demand (session-scoped) or connect to an existing one, and manage test database creation, isolation, and cleanup. The plugin uses psycopg 3 to handle connections and database operations, returning a connected psycopg.Connection object to your test functions.

The plugin supports pre-populating test databases via SQL files or Python functions, with a template-cloning strategy that speeds up test runs by building a template database once per session and cloning it for each test. You can customize fixtures through factory functions, configure connection parameters via command-line options or pytest.ini, and chain multiple fixtures to layer data pre-population. It handles both managed PostgreSQL processes and connections to external instances (e.g., Docker containers).

Use it for

  • Unit testing code that queries or modifies PostgreSQL tables without needing manual database setup or teardown.
  • Integration testing with pre-populated schemas and seed data, using template cloning to avoid repeated setup overhead.
  • Testing against an external PostgreSQL instance in CI/CD by using the noproc fixture to connect to a running server.
  • Layering test data through chained fixtures, where each fixture adds its own schema or data on top of a previous layer.
  • Testing SQLAlchemy ORM code by creating a session fixture that wraps the postgresql connection.
  • Ensuring test isolation by automatically dropping test databases and terminating leftover connections after each test.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

The plugin is actively maintained, has no known vulnerabilities, and solves a common testing problem with low install friction. Use it if you need to test code that interacts with PostgreSQL and want automated database lifecycle management. The copyleft license does not restrict your application code, only derivative works of the plugin itself.

Install

pytest-postgresql on PyPI

Before you install

Low install friction with a pure-Python wheel. Active maintenance (last commit 2026-08-14) and stable production status. Requires psycopg 3 for the plugin itself, though application code can use psycopg 2.

Requires PostgreSQL >= 14 to be installed on the system; the plugin manages the process but does not bundle PostgreSQL itself.

License in practice

Licensed under LGPLv3+, a copyleft license. Derivative works and modifications must be distributed under compatible terms; using the plugin in a project does not impose copyleft on your own code.

Quickstart

pip install pytest-postgresql psycopg

import pytest
from pytest_postgresql import factories

postgresql_proc = factories.postgresql_proc()
postgresql = factories.postgresql('postgresql_proc')

def test_example(postgresql):
    with postgresql.cursor() as cur:
        cur.execute("CREATE TABLE test (id serial PRIMARY KEY);")
        postgresql.commit()

Verify before relying

  • Whether the plugin works with PostgreSQL versions between 14 and the current release date (2026-08-14).
  • Performance characteristics when chaining multiple fixture layers or pre-populating large schemas.

Package facts

Licensecopyleft license copyleft
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
5 packages
pytestport-formirakurupackagingpsycopg
MaintenanceActively maintained 91 days since the last release
Last repo commit
First released
Downloads6,639,491 / month, #1,876 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)Natural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Evidence: pytest_postgresql-8.1.0-py3-none-any.whl

Tags

Capabilities
pytest postgresql fixturesdatabase testing with pytestpostgresql test databasepytest database fixturespostgresql process managementtest database isolationpostgresql testing plugin
Topics
postgresqltest-fixturesdatabase-testing
PyPI keywords
testspytestfixturepostgresql

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “pytest postgresql fixtures”

  • pytest-postgresqlA pytest plugin that provides fixtures to manage PostgreSQL database…
  • pytest-pgsqlA pytest plugin that provides fixtures for running tests against…
  • py-pglitepy-pglite provides a zero-config PostgreSQL testing environment for…

Give your agent the search over MCP, or paste the wish link into any chat.

More Python Modules packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
PyYAML Worth it
PyPI · Python Modules · released Sep 2025

PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.

MITcompiled wheel · 3.8+
1.2Bdownloads / mo
pydantic Worth it
PyPI · Python Modules · released May 2026

Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.

MITpure Python · 3.9+
1.1Bdownloads / mo
annotated-types Worth it
PyPI · Python Modules · released Jul 2026

Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.

Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…

MITpure Python · 3.10+
871.3Mdownloads / mo
typing-inspection Worth it
PyPI · Python Modules · released Aug 2026

Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.

MITpure Python · 3.10+
783.0Mdownloads / mo

See also pytest-mysql · pytest-redis · pytest-rabbitmq · pytest-pgsql · py-pglite · testgres · fixtures · pytest-shutil · pytest-xprocess · pytest-docker-tools