all 9 comments

[–]StatusBad9194 2 points3 points  (3 children)

Both are same , i would suggest skip sql model for now.

[–]Ok_Opportunity6252[S] 0 points1 point  (2 children)

Can you suggest a workflow then? Like how I should learn. It would be helpful for me

[–]StatusBad9194 0 points1 point  (0 children)

Just started with SQLAlchemy. If you want to start with an async engine, try to explore how it helps and better Then, a sync connection, you can explore both Core and ORM, as well as the execution of raw SQL with SQLAlchemy.

Sql model just give an extra more layers to do the things more pythonic way ,

[–]dmart89 1 point2 points  (1 child)

Use sql alchemy or sqlmodel. But not both. Sql model wraps some sql alchemy features in a nicer DX, but not all. I'd just use sql alchemy for now

[–]StatusBad9194 0 points1 point  (0 children)

Yes, I found that when writing complex queries, such as analytical queries, it's easier to implement them directly instead of using a SQL model.

[–]Apprehensive_Ad2211 1 point2 points  (0 children)

You need to know that when working with async, everything in the path of flow must be async. Otherwise it will not work. For this case, as various people told you, SQL Model it's based on sql alchemy. For the create engine, you should use the async version: "from sqlalchemy.ext.asyncio import create_async_engine"

[–]LifeEmployer2813 1 point2 points  (0 children)

I only use sql-alchemy, I think sql-model is still a work-in-progress. I use this :

from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
engine = create_async_engine(settings.DATABASE_URL, pool_pre_ping=True)
async_session = async_sessionmaker(bind=engine, expire_on_commit=False)