Closed S1SYPHOS closed 6 months ago
Hey, @S1SYPHOS, thanks for the issue!
FastAPI supports Pydantic V2 since June 2023, SQLAlchemy is at 2.0+ since January 2023. SQLModel got proper Pydantic V2 support just last month, SQLAlchemy 2.0 in November 2023.
At least for now, I think this is not the way to go (since Tiangolo is the solo maintainer and FastAPI is the priority, it's very likely that SQLModel will always be far behind Pydantic and SQLAlchemy). Specially since migrating from SQLAlchemy + Pydantic to SQLModel is easier than the other way around. Plus, since SQLModel is just a superset on SQLAlchemy and Pydantic, everything should work properly if you just migrate the models to SQLModel.
It's something I think a lot of people would like though, so I'm thinking about creating a minimal template using SQLModel. What do you think?
Thanks for your thorough explanation, I wasn't quite aware of all points you raised. Also it makes me think about using SQLModel after all 😅
However, having a minimal template (or maybe a commented out example) for people to get going quickly would be super appreciated! 🙏
I think SQLModel is really cool, and it really makes stuff simpler, I stopped using it when FastAPI got Pydantic V2 and SQLModel had no support for it in sight. I still use it when I want to make quick stuff though (building POCs etc).
I'll start creating the SQLModel version as a solution for this issue!
Thank you very much! May I also express my admiration for your fastcrud
project while I'm at it, it's a really cool project!
One reason I use SqlAlchemy directly is because I believe SQLModel does not have support async (https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html) with SqlAlchemy 2.0, does it? is my understanding correct?
As I'm getting more and more familiar with this project, I see the value of keeping both libraries separate 😅
Thank you very much! May I also express my admiration for your
fastcrud
project while I'm at it, it's a really cool project!
Thanks, @S1SYPHOS! Really appreciate it.
One reason I use SqlAlchemy directly is because I believe SQLModel does not have support async (https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html) with SqlAlchemy 2.0, does it? is my understanding correct?
I see no reason for it not to work, since it's just a superset of sqlalchemy with pydantic compatibility built in.
As I'm getting more and more familiar with this project, I see the value of keeping both libraries separate 😅
It's a really cool idea, I just think it's not there yet.
I'd like to express my admiration for this FastAPI-boilerplate project here. Congratulations, @igorbenav!
I also want to share my project fastapi-async-sqlmodel-boilerplate which was inspired/based on this project. In it, I've made the necessary migration from SQLAlchemy + Pydantic to SQLModel:
FastAPI Async SQLModel Boilerplate
I'm using it in production, and it's been great.
Hope it helps someone.
@epicwhale, @S1SYPHOS, @CHE1RON
Hey, @joaoflaviosantos, really cool. More of a Feature-based structure, plus the sqlmodel part, so another option for everyone!
Hey, guys, SQLModel-boilerplate is live and mentioned in the readme! I'd love for you to give it a try.
Closed by #137
I'll have a look later, thanks!
Since the author of FastAPI created SQLModel in order to be able to reduce the amount of code being maintained by combining models of both libraries, how about replacing them with an SQLModel based solution? :wink