sqlmodel: Build Python Models for SQL Databases

Summary
SQLModel combines Pydantic-style data models with SQLAlchemy database mapping in one Python library. It suits FastAPI developers and Python teams who want typed models for validation and database access without maintaining duplicate definitions.
At a glance
- Language
- Python
- License
- MIT
- Stars
- 18.4k
- Forks
- 889
- Added to OSRepos
- December 8, 2025
- Last analyzed
- October 4, 2026
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Overview
SQLModel is a Python library for defining SQL database tables and working with database records through typed Python models. It builds on Pydantic and SQLAlchemy, aiming to reduce duplicated model definitions while retaining compatibility with both libraries.
It is especially relevant to FastAPI applications, where the same model can support database persistence and data validation. The project is a thin layer over established libraries, so it can also fit Python applications that use SQLAlchemy without FastAPI.
Key Features
- Define table models and columns with Python type annotations.
- Use models that work with both SQLAlchemy and Pydantic.
- Create database tables and manage records through SQLModel sessions.
- Build queries with SQLModel's
selectinterface. - Retain access to SQLAlchemy and Pydantic capabilities underneath.
- Use models with FastAPI and benefit from editor completion and inline type feedback.
Use Cases
- FastAPI developers can use shared models for request data and database tables, reducing duplicated definitions.
- Python developers starting a small SQL-backed application can define typed models and interact with a database through familiar Python code.
- Teams with SQLAlchemy applications can consider SQLModel when they want a more concise model layer while keeping SQLAlchemy compatibility.
- Developers who rely on editor completion and type annotations can use SQLModel to make database model fields clearer in their code.
Project Facts
- Language: Python
- License: MIT
- Stars: 18.4k
- Forks: 889
- Topics: fastapi, json, json-schema, pydantic, python, sql, sqlalchemy
- Archived: No
Getting Started
Install with uv add sqlmodel. See the README and official documentation for setup and usage details.
Considerations
- Requires a recent, currently supported Python version.
- Pydantic and SQLAlchemy are required dependencies and are installed with SQLModel.
- SQLModel builds on Pydantic and SQLAlchemy, so its design and behavior are closely tied to those libraries. Consult their documentation when you need capabilities beyond SQLModel's simplified interface.
Found this useful?
Share it with someone who would like sqlmodel.
Comparisons
Source repository
Open the original repository on GitHub.
15 counted GitHub visits
Related repositories
Similar repositories that may be relevant next.

omnigent: Orchestrate AI Coding Agents Across Harnesses
October 5, 2026
Omnigent provides a shared orchestration layer for AI coding agents, with policies, sandboxing, and team collaboration. It suits developers who want to combine agent runtimes and access sessions across devices without tying workflows to one harness.

agentevals: Evaluate AI Agents from OpenTelemetry Traces
October 4, 2026
agentevals scores AI agent behavior from existing OpenTelemetry traces, without rerunning agents or making extra model calls. It suits teams building instrumented agents that need local evaluation, golden-set checks, or CI quality gates.

web-design: Create Consistent Web Pages with a Claude Code Skill
October 3, 2026
web-design is a Claude Code skill that turns product briefs, reference URLs, or screenshots into an editable design specification before generating web code. It is suited to developers and designers who want a repeatable, spec-led workflow for building consistent pages.

oomwoo: Build a DIY Robot Vacuum
October 2, 2026
OOMWOO is a planned, hackable robot vacuum built around Raspberry Pi, ROS2 and 2D LiDAR. It is aimed at makers who want to build and customize a locally controlled vacuum, but its hardware and build instructions are still in development.