pytest-databases

Manage Docker database containers with pytest fixtures for integration testing.

13|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/litestar-org/litestar-skills --skill pytest-databases-litestar-org
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest-databases
Source: https://github.com/litestar-org/litestar-skills/tree/main/plugins/litestar/skills/pytest-databases
Command: npx skills add https://github.com/litestar-org/litestar-skills --skill pytest-databases-litestar-org

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Manually setting up and managing Docker containers for database integration tests is time-consuming, error-prone, and difficult to scale across multiple database types or parallel test runs.

Core Features & Use Cases

  • Pre-built fixtures for 20+ databases: Includes out-of-the-box support for PostgreSQL, MySQL, MongoDB, Redis, BigQuery, Spanner, and other SQL, NoSQL, and cloud database services.
  • Parallel test support: Built-in pytest-xdist integration with configurable isolation levels to prevent data conflicts during parallel test execution.
  • Real-world use case: A developer building a Litestar application can use these fixtures to run integration tests against a real database container without writing custom Docker setup or teardown code.

Quick Start

Add the pytest_databases plugin for your target database to your project's conftest.py file to automatically provision and manage the corresponding Docker container for your tests.

Frequently Asked Questions about pytest-databases

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate Docker container setup for pytest database integration testing?

Automating Docker container setup for pytest database integration testing is done by adding pre-built fixtures to your project, which provision and manage the lifecycle of database containers without requiring manual Docker teardown code.

Does pytest database testing support parallel test execution with isolated states?

Yes, pytest database testing supports parallel execution through built-in pytest-xdist integration, providing configurable isolation levels to prevent data conflicts when running integration tests concurrently across multiple workers.

Can I use pytest fixtures to test against both PostgreSQL and MySQL containers locally?

You can use ready-to-use pytest fixtures to test against both PostgreSQL and MySQL containers locally, with out-of-the-box support spanning over 20 SQL, NoSQL, key-value, and search database services.

What is the best way to run integration tests against real database containers in CI environments?

The best way to run integration tests against real database containers in CI environments is using pre-configured pytest fixtures that eliminate manual Docker lifecycle management and support environment variable overrides for flexible configuration.

Do I need to write custom teardown code for Docker database fixtures during local development?

No, you do not need to write custom teardown code for Docker database fixtures during local development, as the plugin automatically handles container provisioning and lifecycle management for your test suite.

Are there limitations when running Docker database fixtures on ARM architecture for cross-platform testing?

Docker database fixtures do not face ARM architecture limitations for cross-platform testing, as the plugin explicitly provides ARM architecture compatibility to ensure integration tests run smoothly across different processor architectures.