Skip to content
Discussion options

You must be logged in to vote

I just added support for Pydantic's ORM mode in FastAPI 0.30.0. 🎉

ORM mode is new, but it solves most of these cases. You can see the docs here: https://fastapi.tiangolo.com/tutorial/sql-databases/

The docs use examples with SQLAlchemy, but they should work equally for any other ORM. Actually, any object that has attributes (item.name instead of item["name").

It also supports dynamic properties, hybrid attributes, relationships, lazy-loading, etc.

You declare the shape that you need to return in your Pydantic models with all the specific attributes and they take care of extracting the data from your ORM object.

Also, I'm now using quite a lot of Peewee recently for a project 🤷‍♂️ 😁 ...Alt…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
Converted from issue

This discussion was converted from issue #84 on February 28, 2023 14:57.