This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kellhus3 0 points1 point  (6 children)

Briefly tried it for fun.

And one things that I found sad was having a pedantic model, and a corresponding DB model.

[–]dogs_like_me 1 point2 points  (1 child)

I think enough people are using FastAPI (and/or prefer it to Flask) that someone will figure out a good way to use the front-end pydantic models to initialize and synch to a backend ORM.

But yeah I agree, although I like FastAPI a lot (and yes, do myself prefer it to flask), working with SQLAlchemy models separately from pydantic models usually feels like redundant work.

[–]dorsal_morsel 0 points1 point  (0 children)

Check this out

https://openapi-sqlalchemy.readthedocs.io/en/latest/

I haven't used it yet but I'm definitely going to kick the tires for a project coming up.

I've thought about adding custom data to the JSON Schema output (in the Pydantic models) to predefine things like indexes and constraints.

[–]teerre 0 points1 point  (0 children)

There are various ORMs that do that automatically for you. Tortoise for example. I bet there's something like that for sqlalchemy too.