{"id":"239aeb8e-8671-4706-97fd-020a7c86c4ef","shortId":"a2GZSt","kind":"skill","title":"pytest-databases","tagline":"Auto-activate for pytest_databases imports, conftest.py database fixtures, Docker-backed PostgreSQL/MySQL/SQLite/Oracle tests, or integration-test database lifecycle. Use when configuring pytest database containers and fixtures. Not for mocked databases or non-pytest test framewo","description":"# pytest-databases\n\nA pytest plugin providing ready-made database fixtures for testing using Docker containers.\n\n---\n\n<workflow>\n\n## References Index\n\nFor detailed guides and code examples, refer to the following documents in `references/`:\n\n- **[Supported Databases](references/databases.md)**\n  - Examples for PostgreSQL, MySQL, Oracle with service/connection fixtures.\n- **[Complete Reference](references/reference.md)**\n  - Fixture tables for all supported SQL, KV, Search, and Object Storage databases.\n- **[Xdist Parallel Testing](references/xdist.md)**\n  - Isolation levels (database vs server) and helper functions.\n- **[Configuration](references/config.md)**\n  - Fixture overrides and environment variable support.\n- **[Troubleshooting](references/troubleshooting.md)**\n  - ARM architecture tips, port conflicts, and health checks.\n\n## Quick Start\n\n### 1. Enable in Project\n\nAdd to `conftest.py`:\n\n```python\npytest_plugins = [\"pytest_databases.docker.postgres\"]\n```\n\n### 2. Use Fixtures\n\n```python\ndef test_database(postgres_service):\n    # Use postgres_service.host, .port, etc.\n    pass\n```\n\n</workflow>\n\n<guardrails>\n\n## Guardrails\n\n- **Keep fixtures container-based.** Do not monkey-patch or mock the database client — prefer the real service fixture so tests cover driver behavior.\n- **Use `xdist` isolation helpers.** For parallel runs, select the `database`-level or `server`-level isolation fixtures from `references/xdist.md` instead of sharing one schema across workers.\n- **Do not hand-roll container lifecycle.** Rely on the plugin's fixtures; they handle startup, readiness, and teardown.\n- **Scope fixtures to the smallest unit that works.** A session-scoped Docker container with function-scoped schemas is almost always the right trade-off.\n\n</guardrails>\n\n<validation>\n\n## Validation Checkpoint\n\n- [ ] `conftest.py` declares only the database plugins you actually use (`pytest_plugins = [...]`)\n- [ ] Tests pull the correct fixture (`postgres_service`, `mysql_service`, etc.) rather than opening raw connections\n- [ ] Parallel runs (`pytest -n auto`) produce isolated data — verified via `references/xdist.md`\n- [ ] CI runs Docker-in-Docker (or Podman) with enough resources for the requested fixtures\n\n</validation>\n\n<example>\n\n## Example: PostgreSQL integration test\n\n```python\nimport pytest\n\npytest_plugins = [\"pytest_databases.docker.postgres\"]\n\n\n@pytest.mark.asyncio\nasync def test_user_insert(postgres_service, postgres_connection):\n    await postgres_connection.execute(\n        \"INSERT INTO users (email) VALUES ($1)\", \"alice@example.com\"\n    )\n    row = await postgres_connection.fetchrow(\n        \"SELECT email FROM users WHERE email = $1\", \"alice@example.com\"\n    )\n    assert row[\"email\"] == \"alice@example.com\"\n```\n\n</example>\n\n---\n\n## Cross-References\n\n- **[litestar-testing](../litestar-testing/SKILL.md)** — Litestar-specific testing patterns; integrates pytest-databases fixtures with `AsyncTestClient`.\n\n## Official References\n\n- <https://github.com/litestar-org/pytest-databases>\n- <https://litestar-org.github.io/pytest-databases/latest/>\n\n## Shared Styleguide Baseline\n\n- Use shared styleguides for generic language/framework rules to reduce duplication in this skill.\n- [General Principles](../litestar-styleguide/references/general.md)\n- [Testing](../litestar-styleguide/references/testing.md)\n- [Python](../litestar-styleguide/references/python.md)\n- Keep this skill focused on tool-specific workflows, edge cases, and integration details.","tags":["pytest","databases","litestar","skills","litestar-org","advanced-alchemy","agent-skills","agentskills","ai-agents","claude-code-plugin","claude-code-skills","gemini-cli-extension"],"capabilities":["skill","source-litestar-org","skill-pytest-databases","topic-advanced-alchemy","topic-agent-skills","topic-agentskills","topic-ai-agents","topic-claude-code-plugin","topic-claude-code-skills","topic-gemini-cli-extension","topic-htmx","topic-inertia","topic-litestar","topic-mcp","topic-python"],"categories":["litestar-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/litestar-org/litestar-skills/pytest-databases","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add litestar-org/litestar-skills","source_repo":"https://github.com/litestar-org/litestar-skills","install_from":"skills.sh"}},"qualityScore":"0.453","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 7 github stars · SKILL.md body (3,489 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:13:55.440Z","embedding":null,"createdAt":"2026-05-18T13:20:59.799Z","updatedAt":"2026-05-18T19:13:55.440Z","lastSeenAt":"2026-05-18T19:13:55.440Z","tsv":"'/litestar-org/pytest-databases':376 '/litestar-styleguide/references/general.md':398 '/litestar-styleguide/references/python.md':402 '/litestar-styleguide/references/testing.md':400 '/litestar-testing/skill.md':359 '/pytest-databases/latest/':379 '1':133,336,347 '2':144 'across':207 'activ':6 'actual':264 'add':137 'alice@example.com':337,348,352 'almost':248 'alway':249 'architectur':124 'arm':123 'assert':349 'async':320 'asynctestcli':371 'auto':5,287 'auto-activ':4 'await':329,339 'back':16 'base':163 'baselin':382 'behavior':183 'case':413 'check':130 'checkpoint':256 'ci':294 'client':173 'code':66 'complet':86 'configur':27,113 'conflict':127 'conftest.py':11,139,257 'connect':282,328 'contain':30,59,162,214,241 'container-bas':161 'correct':271 'cover':181 'cross':354 'cross-refer':353 'data':290 'databas':3,9,12,23,29,36,45,53,76,100,107,150,172,193,261,368 'declar':258 'def':148,321 'detail':63,416 'docker':15,58,240,297,299 'docker-back':14 'docker-in-dock':296 'document':72 'driver':182 'duplic':392 'edg':412 'email':334,342,346,351 'enabl':134 'enough':303 'environ':118 'etc':156,277 'exampl':67,78,309 'fixtur':13,32,54,85,89,115,146,160,178,199,221,229,272,308,369 'focus':406 'follow':71 'framewo':42 'function':112,244 'function-scop':243 'general':396 'generic':387 'github.com':375 'github.com/litestar-org/pytest-databases':374 'guardrail':158 'guid':64 'hand':212 'hand-rol':211 'handl':223 'health':129 'helper':111,187 'import':10,314 'index':61 'insert':324,331 'instead':202 'integr':21,311,365,415 'integration-test':20 'isol':105,186,198,289 'keep':159,403 'kv':95 'language/framework':388 'level':106,194,197 'lifecycl':24,215 'litestar':357,361 'litestar-org.github.io':378 'litestar-org.github.io/pytest-databases/latest/':377 'litestar-specif':360 'litestar-test':356 'made':52 'mock':35,170 'monkey':167 'monkey-patch':166 'mysql':81,275 'n':286 'non':39 'non-pytest':38 'object':98 'offici':372 'one':205 'open':280 'oracl':82 'overrid':116 'parallel':102,189,283 'pass':157 'patch':168 'pattern':364 'plugin':48,142,219,262,267,317 'podman':301 'port':126,155 'postgr':151,273,325,327 'postgres_connection.execute':330 'postgres_connection.fetchrow':340 'postgres_service.host':154 'postgresql':80,310 'postgresql/mysql/sqlite/oracle':17 'prefer':174 'principl':397 'produc':288 'project':136 'provid':49 'pull':269 'pytest':2,8,28,40,44,47,141,266,285,315,316,367 'pytest-databas':1,43,366 'pytest.mark.asyncio':319 'pytest_databases.docker.postgres':143,318 'python':140,147,313,401 'quick':131 'rather':278 'raw':281 'readi':51,225 'ready-mad':50 'real':176 'reduc':391 'refer':60,68,74,87,355,373 'references/config.md':114 'references/databases.md':77 'references/reference.md':88 'references/troubleshooting.md':122 'references/xdist.md':104,201,293 'reli':216 'request':307 'resourc':304 'right':251 'roll':213 'row':338,350 'rule':389 'run':190,284,295 'schema':206,246 'scope':228,239,245 'search':96 'select':191,341 'server':109,196 'servic':152,177,274,276,326 'service/connection':84 'session':238 'session-scop':237 'share':204,380,384 'skill':395,405 'skill-pytest-databases' 'smallest':232 'source-litestar-org' 'specif':362,410 'sql':94 'start':132 'startup':224 'storag':99 'styleguid':381,385 'support':75,93,120 'tabl':90 'teardown':227 'test':18,22,41,56,103,149,180,268,312,322,358,363,399 'tip':125 'tool':409 'tool-specif':408 'topic-advanced-alchemy' 'topic-agent-skills' 'topic-agentskills' 'topic-ai-agents' 'topic-claude-code-plugin' 'topic-claude-code-skills' 'topic-gemini-cli-extension' 'topic-htmx' 'topic-inertia' 'topic-litestar' 'topic-mcp' 'topic-python' 'trade':253 'trade-off':252 'troubleshoot':121 'unit':233 'use':25,57,145,153,184,265,383 'user':323,333,344 'valid':255 'valu':335 'variabl':119 'verifi':291 'via':292 'vs':108 'work':235 'worker':208 'workflow':411 'xdist':101,185","prices":[{"id":"3fa6e22f-07e7-4bbc-88cc-c454bd1b0aeb","listingId":"239aeb8e-8671-4706-97fd-020a7c86c4ef","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"litestar-org","category":"litestar-skills","install_from":"skills.sh"},"createdAt":"2026-05-18T13:20:59.799Z"}],"sources":[{"listingId":"239aeb8e-8671-4706-97fd-020a7c86c4ef","source":"github","sourceId":"litestar-org/litestar-skills/pytest-databases","sourceUrl":"https://github.com/litestar-org/litestar-skills/tree/main/skills/pytest-databases","isPrimary":false,"firstSeenAt":"2026-05-18T13:20:59.799Z","lastSeenAt":"2026-05-18T19:13:55.440Z"}],"details":{"listingId":"239aeb8e-8671-4706-97fd-020a7c86c4ef","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"litestar-org","slug":"pytest-databases","github":{"repo":"litestar-org/litestar-skills","stars":7,"topics":["advanced-alchemy","agent-skills","agentskills","ai-agents","claude-code-plugin","claude-code-skills","gemini-cli-extension","htmx","inertia","litestar","mcp","python","sqlspec"],"license":"mit","html_url":"https://github.com/litestar-org/litestar-skills","pushed_at":"2026-05-13T16:04:09Z","description":"Opinionated first-party agent skills, plugins, subagents, slash commands, and MCP servers for the Litestar framework ecosystem — publishable to Claude Code, Gemini CLI, Codex CLI, Cursor, OpenCode, and VS Code/Copilot from a single repo.","skill_md_sha":"42b03572cc8aa63c02d049fa04686849f4e457ca","skill_md_path":"skills/pytest-databases/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/litestar-org/litestar-skills/tree/main/skills/pytest-databases"},"layout":"multi","source":"github","category":"litestar-skills","frontmatter":{"name":"pytest-databases","description":"Auto-activate for pytest_databases imports, conftest.py database fixtures, Docker-backed PostgreSQL/MySQL/SQLite/Oracle tests, or integration-test database lifecycle. Use when configuring pytest database containers and fixtures. Not for mocked databases or non-pytest test frameworks."},"skills_sh_url":"https://skills.sh/litestar-org/litestar-skills/pytest-databases"},"updatedAt":"2026-05-18T19:13:55.440Z"}}