Re: [sqlalchemy] Session and context manager

2018-02-05 Thread Mike Bayer
On Mon, Feb 5, 2018 at 8:15 AM, Jacek Blocki wrote: > Mike, > Thank you for for the tip on _sessions, I think it is worth publishing since > it can make debugging easier. Regarding documentation it will be good to > mention session close() is not like file close() and closed

Re: [sqlalchemy] Session and context manager

2018-02-05 Thread Jacek Blocki
Mike, Thank you for for the tip on _sessions, I think it is worth publishing since it can make debugging easier. Regarding documentation it will be good to mention session close() is not like file close() and closed session is just ready for another transaction. Context manager is typically

Re: [sqlalchemy] Session and context manager

2018-01-31 Thread Mike Bayer
On Wed, Jan 31, 2018 at 8:37 AM, Jacek Blocki wrote: > In SQLAlchemy documentation there is an example of handling session with > context manager: > > from contextlib import contextmanager > > @contextmanager > def session_scope(): > """Provide a transactional scope

[sqlalchemy] Session and context manager

2018-01-31 Thread Jacek Blocki
In SQLAlchemy documentation there is an example of handling session with context manager: from contextlib import contextmanager @contextmanagerdef session_scope(): """Provide a transactional scope around a series of operations.""" session = Session() try: yield session