sqlmodel

Connect FastAPI projects to SQL databases using SQLModel ORM models.

1|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/cyr-ius/portalcrane --skill sqlmodel-cyr-ius
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlmodel
Source: https://github.com/cyr-ius/portalcrane/tree/main/.agents/skills/sqlmodel
Command: npx skills add https://github.com/cyr-ius/portalcrane --skill sqlmodel-cyr-ius

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SQLModel unifies ORM models and API schemas for FastAPI by combining Pydantic v2 data validation with SQLAlchemy ORM, enabling type-safe, easily extensible data layers.

Core Features & Use Cases

  • Define table models that also serve as Pydantic schemas to simplify API contracts.
  • Provide CRUD endpoints with shared validation, sessions, and migrations for SQLite, PostgreSQL, or MySQL.
  • Use relationships (one-to-many, many-to-many) and migrations to build production-grade data powered APIs.

Quick Start

Create a FastAPI project, define SQLModel models for your tables, and implement CRUD routes to expose a REST API.

Frequently Asked Questions about sqlmodel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I unify SQLAlchemy ORM models and Pydantic schemas in FastAPI?

SQLModel unifies SQLAlchemy ORM and Pydantic v2 schemas for FastAPI by combining data validation with ORM capabilities. It enables type-safe data layers where table models also serve as API schemas to simplify API contracts.

What is the best way to define CRUD routes and database relationships in FastAPI?

Defining FastAPI CRUD routes and database relationships is best handled with SQLModel. It supports shared validation, session management, and one-to-many or many-to-many relationships to build production-grade data powered APIs.

Can I use SQLModel with PostgreSQL and MySQL backends in FastAPI?

Yes, SQLModel works with PostgreSQL and MySQL backends, as well as SQLite. It connects FastAPI projects to SQL databases by unifying ORM and Pydantic data models for various backend configurations.

How do I manage database sessions and migrations for SQLModel tables?

Managing database sessions and migrations for SQLModel tables requires a project layout that separates models and routers. Clear patterns for CRUD, sessions, and migrations must be established to handle production-grade data powered APIs.

Does FastAPI require separate validation logic when using SQLModel?

FastAPI does not require separate validation logic when using SQLModel. SQLModel combines Pydantic v2 data validation with SQLAlchemy ORM, allowing table models to serve directly as API schemas to ensure type-safe data layers.