SQLModel is a library for interacting with <abbrtitle='Also called "Relational databases"'>SQL databases</abbr> from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.
**SQLModel** is based on Python type annotations, and powered by <ahref="https://pydantic-docs.helpmanual.io/"class="external-link"target="_blank">Pydantic</a> and <ahref="https://sqlalchemy.org/"class="external-link"target="_blank">SQLAlchemy</a>.
The key features are:
* **Intuitive to write**: Great editor support. <abbrtitle="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.
* **Easy to use**: It has sensible defaults and does a lot of work underneath to simplify the code you write.
* **Compatible**: It is designed to be compatible with **FastAPI**, Pydantic, and SQLAlchemy.
* **Extensible**: You have all the power of SQLAlchemy and Pydantic underneath.
* **Short**: Minimize code duplication. A single type annotation does a lot of work. No need to duplicate models in SQLAlchemy and Pydantic.
**SQLModel** is designed to simplify interacting with SQL databases in <ahref="https://fastapi.tiangolo.com"class="external-link"target="_blank">FastAPI</a> applications, it was created by the same <ahref="https://tiangolo.com/"class="external-link"target="_blank">author</a>. 😁
It combines SQLAlchemy and Pydantic and tries to simplify the code you write as much as possible, allowing you to reduce the **code duplication to a minimum**, but while getting the **best developer experience** possible.
**SQLModel** is, in fact, a thin layer on top of **Pydantic** and **SQLAlchemy**, carefully designed to be compatible with both.
This way, you can use conventional Python code with **classes** and **instances** that represent **tables** and **rows**, and that way communicate with the **SQL database**.
### Editor Support
Everything is designed for you to get the best developer experience possible, with the best editor support.
You can learn a lot more about **SQLModel** by quickly following the **tutorial**, but if you need a taste right now of how to put all that together and save to the database, you can do this:
```Python hl_lines="18 21 23-27"
from typing import Optional
from sqlmodel import Field, Session, SQLModel, create_engine
But at the same time, ✨ it is a **SQLAlchemy** model ✨. So, you can combine it and use it with other SQLAlchemy models, or you could easily migrate applications with SQLAlchemy to **SQLModel**.
And at the same time, ✨ it is also a **Pydantic** model ✨. You can use inheritance with it to define all your **data models** while avoiding code duplication. That makes it very easy to use with **FastAPI**.