r/FastAPI • u/rj0_1_ • May 19 '21
Question Writing models on fastapi is difficult with sqlalchemy.
can anyone recommend better orm similar to django-orm with async support if possible.
5
u/kimaniyyyy May 19 '21
Have a look at https://peewee-async.readthedocs.io/en/latest/. I have used is before with sanic for async queries.
4
u/Nick0tin May 19 '21
I use tortoise-orm, I love using it and would recommend for use with FastAPI. It's interface is similar to django orm(which I preferred) and it is completely asynchronous.
1
u/sambame May 19 '21
How is it with JSONB and textsearch (tsvector)?
1
u/Nick0tin May 19 '21
It works fine for me, the orm has postgres(and MySQL I think) specific fields beside common field types.
1
u/sasmariozeld May 26 '21
Fullstack python has some helpful links for sqlalchemy, yeah it can be weird but sqlalchemy is so good that it is one of the main reasons to use python imo
0
u/nicolaballotta May 19 '21
Yeah I’m also curious to know what’s difficult. I’m using it with Sqlalchemy and it looks pretty easy.
And btw why you need async for the db?
0
May 19 '21
[deleted]
2
7
u/Deadly_chef May 19 '21
What exactly is difficult about writing models for you?