@contextmanager
def session_scope(session):
    try:
        yield session
        session.commit()
    except:
        session.rollback()
        raise
    finally:
        session.close()
Provide a transactional scope around a series of operations.
dataset/ETHPy150Open ottogroup/palladium/palladium/util.py/session_scope