Async patterns for FastAPI + SQLAlchemy 2.0

Community

Async data access for FastAPI + SQLAlchemy

Authorchrysa
Version1.0.0
Installs0

System Documentation

What problem does it solve?

FastAPI applications often struggle with safely creating and disposing database connections in an asynchronous context, leading to leaked connections, inconsistent sessions, and test fragility.

Core Features & Use Cases

  • Lifespan-managed engine and per-app session factory to avoid module-level state.
  • Repository pattern for clean data access.
  • Async testing strategies with fixtures and dependency overrides.
  • Guidance on background tasks and proper pool tuning.
  • Clear forbidden patterns to avoid anti-patterns.

Quick Start

Wire an async lifespan to create and dispose the engine, expose a session factory via app.state, implement a repository for data access, and adopt the provided testing setup for async code.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: Async patterns for FastAPI + SQLAlchemy 2.0
Download link: https://github.com/chrysa/shared-standards/archive/main.zip#async-patterns-for-fastapi-sqlalchemy-2-0

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 510,000+ vetted skills library on demand.