{"id":24421,"library":"pytest-databases","title":"pytest-databases","description":"Reusable pytest fixtures for spinning up and tearing down real database containers (PostgreSQL, MySQL, Redis, MongoDB, and more) using Docker or podman. Current version 0.17.0, actively maintained by Litestar-org with monthly releases.","status":"active","version":"0.17.0","language":"python","source_language":"en","source_url":"https://github.com/litestar-org/pytest-databases","tags":["testing","pytest","fixtures","databases","docker","postgresql","mysql","redis","mongodb"],"install":[{"cmd":"pip install pytest-databases","lang":"bash","label":"Core installation"}],"dependencies":[{"reason":"Core testing framework required.","package":"pytest","optional":false},{"reason":"Required for container management.","package":"docker","optional":false}],"imports":[{"wrong":"from pytest_databases import postgresql_fixture","symbol":"postgresql_fixture","correct":"from pytest_databases import postgresql_fixture"}],"quickstart":{"code":"import pytest\nfrom pytest_databases import postgresql_fixture\n\n# Use the fixture directly\npytest_plugins = ['pytest_databases']\n\ndef test_database(postgresql_fixture):\n    # postgresql_fixture yields a connection URL string\n    db_url = postgresql_fixture\n    assert 'postgresql://' in db_url\n","lang":"python","description":"Minimal test using the PostgreSQL fixture. The fixture automatically starts a container and yields the connection URL. No configuration needed if Docker is available."},"warnings":[{"fix":"Use the URL with your database library: `engine = create_engine(postgresql_fixture)`.","message":"The fixture yields a connection URL string, not a database client. You must use it to create your own connection or integrate with an ORM (e.g., SQLAlchemy).","severity":"gotcha","affected_versions":"all"},{"fix":"Add `isolation_mode='server'` to the fixture decorator or mark test with `@pytest.mark.isolation_mode('server')`.","message":"From v0.13.0 onward, some fixtures (e.g., Redis) no longer use server isolation mode by default. If you relied on isolated containers per test, you may need to set `isolation_mode='server'` explicitly.","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"Ensure Docker is installed and running, or set the environment variable `PYTEST_DATABASES_DOCKER_CMD` to your container runtime (e.g., `podman`).","message":"The library requires Docker or podman to be running. If the container runtime is unavailable, tests will fail with a connection error.","severity":"gotcha","affected_versions":"all"},{"fix":"Import as `from pytest_databases import mongodb_fixture` and avoid naming collisions by using aliasing.","message":"In v0.16.0, MongoDB support was added. The fixture name `mongodb_fixture` may conflict with other packages. Import using the full path if needed.","severity":"breaking","affected_versions":">=0.16.0"},{"fix":"Use a different database or emulate x86_64 with Rosetta 2. Alternatively, fall back to a cloud-hosted Oracle instance.","message":"Some fixtures (Oracle) require specific Docker images that may not be available on all architectures. In particular, Oracle 18c XE does not support ARM (Apple Silicon).","severity":"gotcha","affected_versions":">=0.12.0"}],"env_vars":null,"search_vec":"'0.17.0':28 'activ':29 'contain':15 'current':26 'databas':3,14,41 'docker':23,42 'fixtur':6,40 'litestar':33 'litestar-org':32 'maintain':30 'mongodb':19,46 'month':36 'mysql':17,44 'org':34 'podman':25 'postgresql':16,43 'pytest':2,5,39 'pytest-databas':1 'real':13 'redi':18,45 'releas':37 'reusabl':4 'spin':8 'tear':11 'test':38 'use':22 'version':27","created_at":"2026-05-01T08:12:59.272200+00:00","updated_at":"2026-05-01T08:12:59.272200+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'postgresql_fixture' from 'pytest_databases' (/tmp/tmp5dwgcvpp/venv/lib/python3.12/site-packages/pytest_databases/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.19.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/litestar-org/pytest-databases#readme","docs":"https://github.com/litestar-org/pytest-databases#readme","changelog":null,"pypi":"https://pypi.org/project/pytest-databases/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}