News for hackers. Stuff that matters.
Re:SQLModel – SQL Databases in FastAPI by kbumsik on Tuesday August 24, 2021 @06:34PM (#28295823)
Cool project!

Just wanted to mention that you emphasize "optimized for FastAPI" but it looks like it does nothing to do with FastAPI.

Do you have any reason to narrow down the scope to FastAPI when other frameworks like Flask are still more widely used?

Specifically mentioning only one framework causes loosing interest of people who use other frameworks.

Re:SQLModel – SQL Databases in FastAPI by dkh on Tuesday August 24, 2021 @11:55PM (#28297892)
Flask was incredible and a joy to build with, but it's not the future. It's only the present in that so any legacy apps exist that use it and because people who don't knew better will likely still stumble upon it first and use it for their new project.

But we are at the point where async python has really taken off, as well as where the performance gains are just impossible to ignore except for apps thats are either dead-simple or that are super CPU-bound. And FastAPI is unquestionably leading the pack with regards to async frameworks, so it makes sense to target that. (Also, yes, he's the creator.)

(Additionally, FastAPI is using Starlette under-the-hood, which is built on ASGI, part of the point of which is to standardize async servers and frameworks to allow for wide compatibility. Anything that works on Starlette or any ASGI framework will work with FastAPI, and vice versa unless the component is tightly coupled to FastAPI-specific code.)

Re:SQLModel – SQL Databases in FastAPI by aniforprez on Wednesday August 25, 2021 @05:10AM (#28299421)
New Flask 2.0 supports async views and handlers though they admit it's not as performant as async-first frameworks

But I agree largely that Flask is now a thing of the past. If you want to very quickly bring a small API server or a simple view page up then it's fine. For almost anything more complex, it's a huge pain. The ecosystem is extremely fragmented and lots of vital plugins for core systems like caching, auth and such aren't maintained anymore. For someone starting a new project, even if it's a very small web server I'd prefer FastAPI

Re:SQLModel – SQL Databases in FastAPI by nomdep on Tuesday August 24, 2021 @11:26PM (#28297754)
> Do you have any reason to narrow down the scope to FastAPI when other frameworks like Flask are still more widely used?

Because he is the author of FastAPI

Re:SQLModel – SQL Databases in FastAPI by tiangolo on Wednesday August 25, 2021 @06:41AM (#28299925)
You can use it with anything you want, it's independent of any framework.

But as @tomnipotent says below, a SQLModel is also a Pydantic model, so, you can use the same model to do automatic API data validation, serialization, documentation, filtering... and now, also define the database.

There's no more integration, apart from the fact that I built it to do just that, and I made sure everything works just right with FastAPI.

But for any other framework that doesn't have automatic data validation, documentation, serialization, etc. (and you are just doing that by hand) it's an even simpler problem, so SQLModel will work just right, as any other ORM.

Re:SQLModel – SQL Databases in FastAPI by tedmiston on Tuesday August 24, 2021 @10:59PM (#28297583)
> Do you have any reason to narrow down the scope to FastAPI when other frameworks like Flask are still more widely used?

FastAPI is basically the (async) 2021 version of Flask just built on Starlette instead.

If you have used Flask before, the learning curve will be pretty low, and the documentation is great.

But of course people have been using SQLAlchemy and Flask together for ages so I don't see any reason you couldn't use this with Flask instead if you prefer. That said, I bet you'll be able to whip up the MVP even faster using FastAPI.

I do not have any affiliation with the project other than being a happy user today.

Re:SQLModel – SQL Databases in FastAPI by tomnipotent on Tuesday August 24, 2021 @10:51PM (#28297536)
> but it looks like it does nothing to do with FastAPI

A SQLModel is also a Pydantic model. FastAPI uses Pydantic.