Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Project Status
CI/CD Latest Release ci Documentation Building
Quality Coverage Quality Gate Status Maintainability Rating Reliability Rating Security Rating
Package PyPI - Version PyPI - Support Python Versions
Community Discord Matrix Medium Twitter Blog
Meta Litestar Project types - Mypy License - MIT Litestar Sponsors linting - Ruff code style - Ruff

Pytest Databases

Ready-made database and cloud emulator fixtures for your pytest tests.

Features

  • 🚀 Clientless container fixtures with zero required database driver dependencies in the base package
  • 🔄 Support for 20+ relational, NoSQL, analytical, streaming, and cloud emulator services
  • 🐳 Docker and Podman runtime support with deterministic session ownership and pytest-xdist isolation
  • ⚡ Fast readiness checks using standard library probes and in-container CLI tools
  • 🔧 Configurable via pytest CLI options, pyproject.toml, and environment variables

pytest-databases manages the startup and shutdown of database and cloud emulator services in Docker or Podman containers. The following services are available:

  • PostgreSQL / pgvector / ParadeDB: PostgreSQL 11–18, pgvector, and ParadeDB
  • Google AlloyDB Omni: PostgreSQL-compatible AlloyDB Omni 15–18
  • MySQL: MySQL 5.6, 5.7, 8.0, 8.4 LTS, 9.6, and 9.7
  • MariaDB: MariaDB 11.3, 11.4 LTS, 11.8 LTS, 12.2, 12.3, and 13.0
  • Dolt: Versioned MySQL-compatible database
  • Oracle Database: Oracle 18c XE, 23ai Free, and Autonomous Database Free (23ai) with wallet extraction
  • Microsoft SQL Server: SQL Server 2022 and 2025
  • IBM Db2: Db2 Community Edition 12.1 (icr.io/db2_community/db2:12.1.5.0)
  • Google Cloud Spanner: Cloud Spanner emulator
  • Google BigQuery: BigQuery emulator (goccy/bigquery-emulator)
  • Snowflake: Embucket Snowflake-compatible SQL emulator (embucket/embucket:0.2.2)
  • CockroachDB: Distributed SQL database
  • YugabyteDB: Distributed PostgreSQL-compatible database
  • MongoDB: Document database
  • GizmoSQL: Apache Arrow Flight SQL service (DuckDB and SQLite backends)
  • Redis / Valkey / Dragonfly / KeyDB: In-memory key-value stores
  • Elasticsearch: Elasticsearch 7, 8, and 9
  • Azure Blob Storage: Azurite emulator
  • MinIO and RustFS: S3-compatible object storage
  • Redpanda: Kafka-compatible streaming platform
  • LocalStack: LocalStack-compatible AWS emulator (default image MiniStack ministackorg/ministack:latest)
  • Google Cloud Pub/Sub: Cloud Pub/Sub emulator
  • RabbitMQ: RabbitMQ 4.3 with the management plugin
  • Floci: Floci emulators for AWS, Azure, GCP, and OCI, one container per cloud
  • SAP ASE (Sybase): SAP Adaptive Server Enterprise 16.0 (datagrip/sybase:16.0)
  • SAP SQL Anywhere: SQL Anywhere 16 (jaschweder/sybase:latest)
  • Cloudflare KV, R2, and D1: Miniflare 5 Local Explorer and R2 S3 APIs in a node:22-slim container
  • PostgreSQL template databases: build the schema once and clone it per test database ("template" isolation)
  • Embedded PostgreSQL: local initdb/postgres binaries without a container runtime (embedded-postgres extra)

Installation

pip install pytest-databases

Quick Start

  • Add to your pytest conftest.py:
pytest_plugins = ["pytest_databases.docker.postgres"]
  • Use in your tests:
from pytest_databases.docker.postgres import PostgresService
import psycopg


def test_one(postgres_service: PostgresService) -> None:
    with psycopg.connect(
        f"postgresql://{postgres_service.user}:{postgres_service.password}@{postgres_service.host}:{postgres_service.port}/{postgres_service.database}",
        autocommit=True,
    ) as conn:
        result = conn.execute("SELECT 1")
        assert result

Documentation

Full documentation is available at https://litestar-org.github.io/pytest-databases/latest/

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • The Litestar Framework team
  • The pytest community

Metadata

Release files for pytest-databases 0.20.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-databases 0.20.0b1
File Size Uploaded Provenance Actions
pytest_databases-0.20.0b1.tar.gz 495.1 kB With provenance Details for pytest_databases-0.20.0b1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-databases 0.20.0b1
File Interpreter ABI Platform Actions
pytest_databases-0.20.0b1-py3-none-any.whl Python 3 none any Details for pytest_databases-0.20.0b1-py3-none-any.whl

Total release size: 636.9 kB

Release files / pytest_databases-0.20.0b1.tar.gz

Download URL pytest_databases-0.20.0b1.tar.gz
Size 495.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d63422b8e0610d23c1d78f8d430495cd160a47ab0d3c3858430dd98d67d6b0e0
BLAKE2b-256 checksum
How to use checksums
8993f8856358a2070f4edf7023f72bb4c7a4c6c88851338544369afb00cec07b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / pytest_databases-0.20.0b1-py3-none-any.whl

Download URL pytest_databases-0.20.0b1-py3-none-any.whl
Size 141.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15c444f84ef35a3078ffc273f4f337a0df89f65009b540e650ec7b02fa0f0539
BLAKE2b-256 checksum
How to use checksums
4db16e93f308201505b2f5b56e0b2468657a64d7f036be3747d6483c873f5c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for pytest-databases 0.20.0b1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_databases-0.20.0b1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page