foortex.codegen utility
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 Boilerplate
fastapi-sqlalchemy2-async-pg.ts
1from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
2from sqlalchemy.orm import DeclarativeBase
3
4DATABASE_URL = "postgresql+asyncpg://user:pass@localhost/dbname"
5engine = create_async_engine(DATABASE_URL, echo=True)
6AsyncSessionLocal = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
7
8async 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.

Deploy