Pytest Databases
Ready-made database fixtures for your pytest tests.
Features
- 🚀 Easy-to-use database fixtures
- 🔄 Support for multiple database types
- 🐳 Docker integration for isolated testing environments
- ⚡ Fast and efficient test execution
- 🔧 Highly configurable
pytest-databases uses the Docker Python SDK to manage the startup and shutdown of database services in containers. The following databases are currently available:
- Postgres: Version 12, 13, 14, 15, 16, 17 and 18 are available
- MySQL: Version 5.6, 5.7 and 8 are available
- Oracle: Version 18c XE and 23C Free are available
- SQL Server: Version 2022 is available
- Google AlloyDB Omni: Simplified Omni installation for easy testing.
- Google Spanner: The latest cloud-emulator from Google is available
- Google BigQuery: Unofficial BigQuery emulator
- CockroachDB: Version latest is available
- Redis: Latest version
- Valkey: Latest version
- Dragonfly: Latest version
- KeyDB: Latest version
- Elasticsearch: Version 7 and 8 are available
- Azure blob storage: Via azurite
- Minio: Latest version
Installation
Quick install for postgres:
pip install pytest-databases[postgres]
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
Release files for pytest-databases 0.19.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_databases-0.19.0.tar.gz | 350.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_databases-0.19.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 391.6 kB
Release files / pytest_databases-0.19.0.tar.gz
| Download URL | pytest_databases-0.19.0.tar.gz |
|---|---|
| Size | 350.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba7b8e51b551455daf3bd144384f6d4fba23d747b001f071795b02e6be2a3cbf
|
|
BLAKE2b-256 checksum How to use checksums |
ab4ee899556b3876eec2db9bd630ad3054ced94a9541c26319bec5c4cd00579d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 23, 2026.
Transparency logRelease files / pytest_databases-0.19.0-py3-none-any.whl
| Download URL | pytest_databases-0.19.0-py3-none-any.whl |
|---|---|
| Size | 41.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d14651e23a716ed6f2317bf9ac317c9e7891db701253abf78e9cef1049e8f26b
|
|
BLAKE2b-256 checksum How to use checksums |
def4d6e2edae47a0421a8531a9805fb787b993380222f00dc25cee1634f55f3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 23, 2026.
Transparency log