You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQL databases in Python, designed for simplicity, compatibility, and robustness.
Details
SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.
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.
Features
SQLModel is based on Python type annotations, and powered by Pydantic and SQLAlchemy. The key features are:
Intuitive to write: Great editor support. Completion 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.
Standing on the shoulders of giants
Application model classes derive from an SQLModel model.
By doing so, your model class becomes an SQLAlchemy model at the same time. So, you can combine it and use it with other SQLAlchemy models, or you could easily migrate applications with SQLAlchemy to SQLModel.
At the same time, it also becomes 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.
pitchA pitch for adding a new integration item, after evaluating it, and writing a tutorial
1 participant
Converted from issue
This discussion was converted from issue #172 on December 05, 2024 21:03.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
About
SQL databases in Python, designed for simplicity, compatibility, and robustness.
Details
SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.
Features
SQLModel is based on Python type annotations, and powered by Pydantic and SQLAlchemy. The key features are:
Standing on the shoulders of giants
Application model classes derive from an SQLModel model.
By doing so, your model class becomes an SQLAlchemy model at the same time. So, you can combine it and use it with other SQLAlchemy models, or you could easily migrate applications with SQLAlchemy to SQLModel.
At the same time, it also becomes 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.
Resources
Beta Was this translation helpful? Give feedback.
All reactions