Aug 22, 2023
You are absolutely right,
The tutorial was meant to have a simple implementation.
I of course do not recommend this in production.
In prod, sessions are created for every view function using dependency injection as recommended in the fastapi docs.
However, I appreciate your feedback and perhaps I should consider that readers might try to use this code in production as is.
Perhaps I should hint it somewhere at least.
I am writing another article in fact focusing on sqlalchemy 2.0 syntax and I will have a better implementation there while keeping it simple