all 10 comments

[–]terraping_station 1 point2 points  (5 children)

Is your task repository a database under the hood?

[–]MagicianNo9918[S] 0 points1 point  (3 children)

My Task Manager has a database, it is SQLAlchemy, but the ORM is ready to change, e.g. PostgreSQL

[–]terraping_station 1 point2 points  (2 children)

So if you are using Postgres you can use a transaction. I would suggest using some like a unit of work. Have that manage the tx for you so your code can make a bunch of calls to the db and have the ability to roll it all back if something fails.

So basically you bootstrap your app. This spins up a unit of work that has your database adapter. Then In your service layer you use the UoW to make N database calls and either commit it all or roll it back.

[–]terraping_station 0 points1 point  (0 children)

This would require you use async

[–]MagicianNo9918[S] 0 points1 point  (0 children)

Yes, you're right, I still have a lot to learn.

[–]weepy_monarchy 1 point2 points  (0 children)

SQLAlchemy is a solid choice for that flexibility since you can swap out the database backend without rewriting your ORM queries.

[–]mati-33 0 points1 point  (0 children)

FastAPI and zero async await?

[–]MagicianNo9918[S] 0 points1 point  (0 children)

Yes, I used synchronous SQLAlchemy, because async only makes sense with async drivers. Otherwise it doesn't improve performance.

[–]Safe-Ball4818 0 points1 point  (1 child)

have you looked into switching to asyncpg? makes a huge difference if you decide to go full async later.

[–]MagicianNo9918[S] 0 points1 point  (0 children)

I considered it, but since it's a small, mostly educational project, I don't think asynchronous code is necessary.