$npx skillfedfor your agent

pytest-databases

Reusable database fixtures for any and all databases.

With conditionsPyPI TestingReleased May 202674.4K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_databases-0.19.0-py3-none-any.whl
v0.19.0 · released 2026-05-23 · Python >=3.9 · 3 runtime deps: docker, filelock, pytest

Yes, if you need real database testing in a containerized environment. The low install friction, active maintenance, permissive license, and broad database support make it a solid choice for integration tests. The main gotcha is the Docker dependency—you must have Docker running, and container startup adds latency per test. For unit tests or projects that cannot use Docker, this is not the right tool.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Docker to be installed and running on the system; the package manages database container lifecycle but does not provide Docker itself.
  • Low friction installation with a pure Python wheel.
  • Maintenance is active with a recent release; the package is in Beta status and depends on docker, filelock, and pytest—all stable, widely-used libraries.

License · maintenance · safety

MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.

last release 2026-05-23 (83 days) · last repo commit 2026-07-22 · 58 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 74,438 downloads/mo, #14,830 on PyPI

Verify before relying

pip install pytest-databases[postgres]

# In conftest.py:
pytest_plugins = ["pytest_databases.docker.postgres"]

# In test file:
from pytest_databases.docker.postgres import PostgresService

def test_example(postgres_service: PostgresService):
    # Use postgres_service.host, .port, .user, .password, .database
  • Whether all listed database versions (Postgres 12–18, MySQL 5.6–8, Oracle 18c/23c, SQL Server 2022) are actively maintained in the fixture set.
  • Performance characteristics and overhead of spinning up containers per test or per session.
  • Whether the package handles cleanup and resource limits to prevent orphaned containers in CI/CD environments.
Same gist for agents: .md · .json

What it is and what it does

pytest-databases is a pytest plugin that provides ready-made fixtures for running database services in Docker containers during tests. Instead of mocking or using in-memory databases, it lets you test against real database instances—Postgres, MySQL, Oracle, SQL Server, Redis, Elasticsearch, and others—each isolated in its own container. The plugin handles container startup, configuration, and teardown automatically.

You declare which database you want in your conftest.py, then inject the service fixture into your test functions. The fixture exposes connection details (host, port, user, password, database name) so you can connect with your normal database client library. This approach trades setup time for test fidelity: your tests run against the actual database engine, not a mock, catching real schema and driver issues before production.

Use it for

  • Integration testing a web application against a real Postgres or MySQL database without manual container management.
  • Testing database migrations and schema changes against multiple database versions in parallel CI jobs.
  • Validating ORM queries and raw SQL against Oracle or SQL Server in a containerized test environment.
  • Testing Redis or Elasticsearch client code with a real service instance isolated per test run.
  • Verifying multi-database support in a library by running the same test suite against Postgres, MySQL, and CockroachDB fixtures.

Worth the install?

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

With conditions

Yes, if you need real database testing in a containerized environment.

The low install friction, active maintenance, permissive license, and broad database support make it a solid choice for integration tests. The main gotcha is the Docker dependency—you must have Docker running, and container startup adds latency per test. For unit tests or projects that cannot use Docker, this is not the right tool.

Install

pytest-databases on PyPI

Before you install

Low friction installation with a pure Python wheel. Maintenance is active with a recent release; the package is in Beta status and depends on docker, filelock, and pytest—all stable, widely-used libraries.

Requires Docker to be installed and running on the system; the package manages database container lifecycle but does not provide Docker itself.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.

Quickstart

pip install pytest-databases[postgres]

# In conftest.py:
pytest_plugins = ["pytest_databases.docker.postgres"]

# In test file:
from pytest_databases.docker.postgres import PostgresService

def test_example(postgres_service: PostgresService):
    # Use postgres_service.host, .port, .user, .password, .database

Verify before relying

  • Whether all listed database versions (Postgres 12–18, MySQL 5.6–8, Oracle 18c/23c, SQL Server 2022) are actively maintained in the fixture set.
  • Performance characteristics and overhead of spinning up containers per test or per session.
  • Whether the package handles cleanup and resource limits to prevent orphaned containers in CI/CD environments.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.9
Install frictionLow. Pure-Python wheel
Runtime dependencies
3 packages
dockerfilelockpytest
MaintenanceActively maintained 83 days since the last release
Last repo commit
First released
Downloads74,438 / month, #14,830 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Evidence: pytest_databases-0.19.0-py3-none-any.whl

Tags

Capabilities
pytest database fixturesdocker database testingisolated test databasespytest postgres fixturecontainerized database testsmulti-database test setuppytest mysql oracle redis
Topics
docker-integrationdatabase-testingfixtures
PyPI keywords
alloydballoydbomniazurebigquerycockroachdbdatabasedoltdbdragonflydbduckdbelasticsearchflightsqlgizmosqlmigrationmongodbmssqlmysqloraclepostgresredisspannervalkey

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 › “isolated test databases”

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

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also pytest-mock-resources · pytest-pgsql · testcontainers-core · testcontainers · pytest-redis · pytest-mysql · pytest-postgresql · py-pglite · testing.common.database · testing.postgresql