Installation#

pytest-databases requires Python 3.11 or later.

uv add --dev pytest-databases
pip install pytest-databases
pdm add --dev pytest-databases
poetry add --group dev pytest-databases

All *_service container fixtures check readiness with Python’s standard library or with tools bundled inside the container image, so the base package does not install any database driver. Install the client library your application already uses alongside pytest-databases.

Embedded PostgreSQL#

The embedded PostgreSQL service runs local initdb / postgres binaries instead of a container. The embedded-postgres extra installs them (pgembed on Python 3.12+, pgserver on Python 3.11); without it the service uses PostgreSQL from PG_BIN_DIR, the PATH, or pg_config --bindir.

uv add --dev "pytest-databases[embedded-postgres]"
pip install "pytest-databases[embedded-postgres]"
pdm add --dev "pytest-databases[embedded-postgres]"
poetry add --group dev "pytest-databases[embedded-postgres]"

Optional Extras#

The extras below remain for projects that pin pytest-databases[<extra>]. Apart from embedded-postgres, none of them is needed by a *_service fixture; the ones that install a package only pull in a client for your own tests or for a deprecated client fixture.

Available extras#

Extra

Installs

Notes

azure, azure-blob, azure-storage

azure-storage-blob

Same contents. azure-storage is the v0.19.0 name.

bigquery

google-cloud-bigquery

Used by the deprecated bigquery_client fixture.

embedded-postgres

pgembed (Python 3.12+) or pgserver (Python 3.11)

PostgreSQL server binaries for embedded_postgres_service.

gizmosql

adbc-driver-flightsql, pyarrow

Used by the deprecated gizmosql_connection fixture.

postgres

psycopg>=3

Used by the deprecated PostgreSQL-family *_connection fixtures.

redis, dragonfly, keydb

redis

Same contents.

spanner

google-cloud-spanner

Used by the deprecated spanner_connection fixture.

cockroachdb, elasticsearch7, elasticsearch8, mongodb, oracle, valkey

nothing

Installed a driver in v0.19.0 (psycopg, elasticsearch7, elasticsearch8, pymongo, oracledb, valkey). Install the driver directly if you use the deprecated client fixtures.

mariadb, mssql, mysql, yugabyte

nothing

Empty since v0.19.0.

Providers without an extra (Db2, Dolt, Floci, LocalStack, MinIO, Pub/Sub, RabbitMQ, Redpanda, RustFS, Snowflake, and the rest) only need the base package.