scoped_session(sessionmaker()) or plain sessionmaker() in sqlalchemy?

Reading the documentation is recommended:

the scoped_session() function is provided which produces a thread-managed registry of Session 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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)