<!-- markdownlint-disable no-inline-html -->
<!-- prettier-ignore-start -->
<div align="center">
| Project | | Status |
| --------- | :-- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CI/CD | | [](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yml) |
| Quality | | [](https://codecov.io/github/litestar-org/pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) |
| Package | | [](https://badge.fury.io/py/pytest-databases)  |
| Community | | [](https://discord.gg/litestar-919193495116337154) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |
| Meta | | [](https://github.com/litestar-org/pytest-databases) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black) |
</div>
# 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:
```bash
pip install pytest-databases[postgres]
```
## Quick Start
- Add to your pytest `conftest.py`:
```py
pytest_plugins = ["pytest_databases.docker.postgres"]
```
- Use in your tests:
```python
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/](https://litestar-org.github.io/pytest-databases/latest/)
## Contributing
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) 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](LICENSE) file for details.
## Acknowledgments
- The Litestar Framework team
- The pytest community
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-databases",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "alloydb, alloydbomni, azure, bigquery, cockroachdb, database, dragonflydb, duckdb, elasticsearch, migration, mssql, mysql, oracle, postgres, redis, spanner, valkey",
"author": null,
"author_email": "Cody Fincher <cody@litestar.dev>",
"download_url": "https://files.pythonhosted.org/packages/33/39/25d33c0246ed8f99ba82fb3c998400bbb704a9874f3eb6791b90f361a043/pytest_databases-0.15.0.tar.gz",
"platform": null,
"description": "<!-- markdownlint-disable no-inline-html -->\n<!-- prettier-ignore-start -->\n<div align=\"center\">\n\n| Project | | Status |\n| --------- | :-- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| CI/CD | | [](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yml) |\n| Quality | | [](https://codecov.io/github/litestar-org/pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) |\n| Package | | [](https://badge.fury.io/py/pytest-databases)  |\n| Community | | [](https://discord.gg/litestar-919193495116337154) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |\n| Meta | | [](https://github.com/litestar-org/pytest-databases) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black) |\n\n</div>\n\n# Pytest Databases\n\nReady-made database fixtures for your pytest tests.\n\n## Features\n\n- \ud83d\ude80 Easy-to-use database fixtures\n- \ud83d\udd04 Support for multiple database types\n- \ud83d\udc33 Docker integration for isolated testing environments\n- \u26a1 Fast and efficient test execution\n- \ud83d\udd27 Highly configurable\n\n`pytest-databases` uses the Docker Python SDK to manage the startup and shutdown of database services in containers. The following databases are currently available:\n\n- **Postgres**: Version 12, 13, 14, 15, 16, 17 and 18 are available\n- **MySQL**: Version 5.6, 5.7 and 8 are available\n- **Oracle**: Version 18c XE and 23C Free are available\n- **SQL Server**: Version 2022 is available\n- **Google AlloyDB Omni**: Simplified Omni installation for easy testing.\n- **Google Spanner**: The latest cloud-emulator from Google is available\n- **Google BigQuery**: Unofficial BigQuery emulator\n- **CockroachDB**: Version latest is available\n- **Redis**: Latest version\n- **Valkey**: Latest version\n- **Dragonfly**: Latest version\n- **KeyDB**: Latest version\n- **Elasticsearch**: Version 7 and 8 are available\n- **Azure blob storage**: Via azurite\n- **Minio**: Latest version\n\n## Installation\n\nQuick install for postgres:\n\n```bash\npip install pytest-databases[postgres]\n```\n\n## Quick Start\n\n- Add to your pytest `conftest.py`:\n\n```py\npytest_plugins = [\"pytest_databases.docker.postgres\"]\n```\n\n- Use in your tests:\n\n```python\nfrom pytest_databases.docker.postgres import PostgresService\nimport psycopg\n\ndef test_one(postgres_service: PostgresService) -> None:\n with psycopg.connect(\n f\"postgresql://{postgres_service.user}:{postgres_service.password}@{postgres_service.host}:{postgres_service.port}/{postgres_service.database}\",\n autocommit=True,\n ) as conn:\n result = conn.execute(\"SELECT 1\")\n assert result\n```\n\n## Documentation\n\nFull documentation is available at [https://litestar-org.github.io/pytest-databases/latest/](https://litestar-org.github.io/pytest-databases/latest/)\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- The Litestar Framework team\n- The pytest community\n",
"bugtrack_url": null,
"license": null,
"summary": "Reusable database fixtures for any and all databases.",
"version": "0.15.0",
"project_urls": {
"Documentation": "https://github.com/litestar-org/pytest-databases#readme",
"Issues": "https://github.com/litestar-org/pytest-databases/issues",
"Source": "https://github.com/litestar-org/pytest-databases"
},
"split_keywords": [
"alloydb",
" alloydbomni",
" azure",
" bigquery",
" cockroachdb",
" database",
" dragonflydb",
" duckdb",
" elasticsearch",
" migration",
" mssql",
" mysql",
" oracle",
" postgres",
" redis",
" spanner",
" valkey"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ef3148b9168189cb62bca61eca2f05a323cb44c7e65b04a43cde5732a95b88f8",
"md5": "421e362d5b88dbd2c5675b5452e5a859",
"sha256": "a2b01053def11264e18fd405ee68c07ce5accafc0872310539bc0d669bbf922c"
},
"downloads": -1,
"filename": "pytest_databases-0.15.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "421e362d5b88dbd2c5675b5452e5a859",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 28734,
"upload_time": "2025-10-06T21:30:46",
"upload_time_iso_8601": "2025-10-06T21:30:46.999408Z",
"url": "https://files.pythonhosted.org/packages/ef/31/48b9168189cb62bca61eca2f05a323cb44c7e65b04a43cde5732a95b88f8/pytest_databases-0.15.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "333925d33c0246ed8f99ba82fb3c998400bbb704a9874f3eb6791b90f361a043",
"md5": "d573c6fbebe32528fc28571a8a11b2f7",
"sha256": "e1b8cda6d1976def17658cc0e9c07ec70aed0126020b724fb3700e2880c15883"
},
"downloads": -1,
"filename": "pytest_databases-0.15.0.tar.gz",
"has_sig": false,
"md5_digest": "d573c6fbebe32528fc28571a8a11b2f7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 215682,
"upload_time": "2025-10-06T21:30:48",
"upload_time_iso_8601": "2025-10-06T21:30:48.504194Z",
"url": "https://files.pythonhosted.org/packages/33/39/25d33c0246ed8f99ba82fb3c998400bbb704a9874f3eb6791b90f361a043/pytest_databases-0.15.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-06 21:30:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "litestar-org",
"github_project": "pytest-databases#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytest-databases"
}