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
Scoped_session at every method will give you a thread of local session which you cannot obtain beforehand (like at the module level).It's not needed to open a new session in every method, You can use a global session , Create a session only when the global session is not available. i.e you can write a method which returns a session and add it to the init.py inside your package.