#!/usr/bin/env python
# -*- coding:utf-8 -*-
import contextlib
from sqlalchemy.orm import sessionmaker
from xiaoli.models.base import engine

__author__ = 'zouyingjun'

Session = sessionmaker(bind=engine)


@contextlib.contextmanager
def db_session_cm():
    session = Session()
    try:
        yield session
    except Exception, e:
        # logger.warn(traceback.format_exc())
        session.rollback()
        raise e
    finally:
        session.close()

abc22c432c841842d04812477ac17110d2b84aac
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import contextlib
from sqlalchemy.orm import sessionmaker
from xiaoli.models.base import engine

__author__ = 'zouyingjun'

Session = sessionmaker(bind=engine)


@contextlib.contextmanager
def db_session_cm():
    session = Session()
    try:
        yield session
    except Exception, e:
        # logger.warn(traceback.format_exc())
        session.rollback()
        raise e
    finally:
        session.close()
