I am using SQlAlchemy in my web project. What should I use - scoped_session(sessionmaker())
or plain sessionmaker()
- and why? Or should I use somethin
Reading the documentation is recommended:
the
scoped_session()
function is provided which produces a thread-managed registry ofSession
objects. It is commonly used in web applications so that a single global variable can be used to safely represent transactional sessions with sets of objects, localized to a single thread.
In short, use scoped_session()
for thread safety.