sqlmodel
SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.
Decision gist · record as of 2026-08-14
Yes. SQLModel is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real pain point—eliminating duplicate model definitions. It's well-suited for FastAPI projects and SQLAlchemy migrations. The 0.0.39 version number signals beta status, so production use should account for potential API changes, but the library is widely used and stable in practice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low friction install with only three runtime dependencies (SQLAlchemy, pydantic, typing-extensions).
- Active maintenance with a recent release and 18266 repository stars; supports current Python versions from 3.10 onward.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
last release 2026-06-25 (50 days) · last repo commit 2026-08-12 · 18,266 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 21,035,871 downloads/mo, #1,017 on PyPI
Alternatives
Verify before relying
pip install sqlmodel
from sqlmodel import Field, Session, SQLModel, create_engine
class Hero(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
name: str
age: int | None = None
engine = create_engine("sqlite:///database.db")
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
hero = Hero(name="Example")
session.add(hero)
session.commit()- Whether async/await support is available for database operations beyond the AsyncIO framework classifier.
- Performance characteristics compared to raw SQLAlchemy or other hybrid ORM solutions.
- Maturity level and backward-compatibility guarantees given the 0.0.39 version number.
What it is and what it does
SQLModel is a thin layer bridging SQLAlchemy and Pydantic, letting you write a single Python class that simultaneously acts as a SQL table definition, an ORM model, and a data validator. Instead of maintaining separate SQLAlchemy models and Pydantic schemas, you annotate class attributes with types and Field() declarations, and SQLModel handles both database persistence and request/response validation. It's built for FastAPI applications but works in any Python codebase that needs SQL databases.
The library handles the boilerplate of mapping Python objects to database rows and back, with full editor autocompletion and type checking throughout. You create instances of your model class to represent rows, pass them to a Session for database operations, and query using SQLAlchemy's select() syntax. Because the same class serves dual duty, you avoid duplicating field definitions and validation logic.
Use it for
- Build FastAPI applications where request/response models and database models are the same class, cutting model definition code in half.
- Migrate existing SQLAlchemy projects to gain Pydantic validation without rewriting your ORM layer.
- Define type-safe database schemas with Python type hints, getting IDE autocompletion for both model creation and query results.
- Reduce boilerplate in data-heavy applications by using one model definition for validation, serialization, and persistence.
- Prototype database-backed services quickly with minimal schema duplication between API contracts and storage.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
SQLModel is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real pain point—eliminating duplicate model definitions. It's well-suited for FastAPI projects and SQLAlchemy migrations. The 0.0.39 version number signals beta status, so production use should account for potential API changes, but the library is widely used and stable in practice.
Install
sqlmodel on PyPI
Before you install
Low friction install with only three runtime dependencies (SQLAlchemy, pydantic, typing-extensions). Active maintenance with a recent release and 18266 repository stars; supports current Python versions from 3.10 onward.
Requires Python 3.10 or later.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install sqlmodel
from sqlmodel import Field, Session, SQLModel, create_engine
class Hero(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
name: str
age: int | None = None
engine = create_engine("sqlite:///database.db")
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
hero = Hero(name="Example")
session.add(hero)
session.commit()
Verify before relying
- Whether async/await support is available for database operations beyond the AsyncIO framework classifier.
- Performance characteristics compared to raw SQLAlchemy or other hybrid ORM solutions.
- Maturity level and backward-compatibility guarantees given the 0.0.39 version number.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesSQLAlchemypydantictyping-extensions |
| Maintenance | Actively maintained 50 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 21,035,871 / month, #1,017 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaFramework :: AsyncIOIntended Audience :: DevelopersIntended Audience :: Science/ResearchIntended Audience :: System AdministratorsProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: DatabaseTopic :: Database :: Database Engines/ServersTopic :: InternetTopic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: HTTP ServersTyping :: Typed |
Evidence: sqlmodel-0.0.39-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “SQL ORM with pydantic validation”
- sqlmodelSQLModel combines SQLAlchemy and Pydantic to let you define SQL…
- ormarAn async ORM for Python that unifies database models with pydantic…
- peeweePeewee is a lightweight ORM that maps Python classes to database…
Give your agent the search over MCP, or paste the wish link into any chat.
More Internet packages
Botocore provides low-level, data-driven access to Amazon Web Services APIs, serving as the foundation for the AWS CLI and boto3 libraries.
Install it if you need programmatic access to AWS services.
Provides an async client for AWS services using botocore and aiohttp, allowing you to call AWS APIs asynchronously within asyncio-based applications.
Install it if you need to call AWS services from async Python code; it is the standard way to do so.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides a platform-independent file locking mechanism to coordinate access to files across processes and threads.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides common Protocol Buffer message definitions used across Google Cloud APIs, enabling Python clients to interact with Google services.
See also ormar · py-automapper · redis-om · sqladmin · SQLAlchemy · databricks-sqlalchemy · prisma · sqlacodegen · sqlalchemy-jdbcapi · PyPika