FastAPIBackend 2510 47.3k
FastAPI SQLAlchemy 2.0 Async Asyncpg Database Repository
Production database setup for FastAPI. Uses SQLAlchemy 2.0 async engine, async session context managers, Pydantic v2 ORM models, and CRUD repository base classes.
SQLAlchemy 2.0 async session context
Fully asyncpg PostgreSQL driver
Interactive Prompt & Options
Fully Editable
Appended directly to the LLM system prompt for tailored code output.
✨ OpenRouter LLM Engine (Llama-3.3-70B) Active
Generated Code
⚡ Instant Boilerplatefastapi-sqlalchemy2-async-pg.ts
| 1 | from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker |
| 2 | from sqlalchemy.orm import DeclarativeBase |
| 3 | |
| 4 | DATABASE_URL = "postgresql+asyncpg://user:pass@localhost/dbname" |
| 5 | engine = create_async_engine(DATABASE_URL, echo=True) |
| 6 | AsyncSessionLocal = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False) |
| 7 | |
| 8 | async def get_db(): |
| 9 | async with AsyncSessionLocal() as session: |
| 10 | yield session |
| 11 |
11 lines • 434 bytesfastapi
Automated Sandbox
Deploy this boilerplate automatically in 1 click.
Related Generators
View AllFastAPI
FastAPI Celery Distributed Background Worker & Redis Broker
Asynchronous job processing setup combining FastAPI, Celery, and Redis for heavy compute tasks, email delivery, and report generation.
FastAPIFastAPI JWT Authentication & Refresh Token Rotation
Production-grade FastAPI auth middleware featuring Argon2id password hashing, JWT access/refresh token rotation, and dependency injection guard.
Next.jsNext.js App Router Stripe Checkout & Webhook Subscription Handler
Complete TypeScript implementation of Stripe Checkout Sessions, Customer Portal redirect, and cryptographically verified Webhook handler for Next.js App Router.