Laravel Eloquent-Style ORM for FastAPI
FasORM brings expressive Active Record models, intuitive relationship eager-loading, automatic JSON serialization, and an artisan-style CLI to modern Python async web applications.
Why FasORM?
Expressive Active Record
Define fields directly as class attributes and use clean Active Record syntax like User.create(...) or User.find(1).
SQLAlchemy 2.0 & Alembic Engine
Built directly on SQLAlchemy 2.0 async engine and Alembic, providing enterprise reliability and full migration support.
Eager Loading & with_count
Eliminate N+1 query problems with intuitive eager loading (with_("posts")) and relation count aggregations (with_count("posts")).
Artisan-Style CLI
Scaffold models, run migrations, generate seeders, and inspect migration status with the powerful fasorm CLI.
Quickstart in 5 Minutes
Get up and running with FasORM in just a few simple steps:
1. Installation
pip install fasorm
2. Initialize your project
fasorm init
3. Define a Model & Migration
from fasorm import Model, String, Boolean, HasMany
class User(Model):
name = String()
email = String(unique=True)
is_active = Boolean(default=True)
posts = HasMany("Post")
4. Perform Queries in FastAPI
from fastapi import FastAPI
from fasorm import init_db
from app.models.user import User
app = FastAPI()
# Initialize DB connection on startup
init_db("sqlite+aiosqlite:///app.db")
@app.get("/users")
async def get_users():
# Eager-load posts and count related records
users = await User.with_count("posts").where(is_active=True).to_dict()
return {"data": users}
Explore Documentation
Installation & DB Drivers →
Learn how to connect to PostgreSQL, MySQL, SQLite, and configure pooling options.
Models & 30+ Field Types →
Explore all available field types, Active Record methods, and automatic serialization.
Fluent Query Builder →
Master filtering, eager loading, relation counting, pagination, and aggregates.
FastAPI Integration →
Build a production-grade FastAPI application step-by-step with FasORM.