예제 #1
0
파일: __init__.py 프로젝트: bladams/keg
    def testing_scoped_session(self):
        # don't want to have to import this if we are in production, so put import
        # inside of the method
        from flask.ext.webtest import get_scopefunc

        # flask-sqlalchemy creates the session when the class is initialized.  We have to re-create
        # with different session options and override the session attribute with the new session
        db.session = db.create_scoped_session(options={'scopefunc': get_scopefunc()})
예제 #2
0
파일: __init__.py 프로젝트: jamlamberti/keg
    def testing_scoped_session(self):
        # don't want to have to import this if we are in production, so put import
        # inside of the method
        from flask.ext.webtest import get_scopefunc

        # flask-sqlalchemy creates the session when the class is initialized.  We have to re-create
        # with different session options and override the session attribute with the new session
        db.session = db.create_scoped_session(
            options={'scopefunc': get_scopefunc()})
예제 #3
0
    def create_database(self, use_migrations=True):
        self.db.session = self.db.create_scoped_session({
            'scopefunc': get_scopefunc(),
        })

        self.db.session.execute('SET storage_engine=InnoDB;')
        if use_migrations:
            try:
                self.db.session.execute('TRUNCATE alembic_version;')
            except sqlalchemy.exc.ProgrammingError:
                self.db.session.rollback()
            config = Config('migrations/alembic.ini', 'alembic')
            alembic_upgrade(config, 'head')
        else:
            self.db.create_all()
예제 #4
0
def make_db(app):
    session_options = {}
    if app.testing:
        session_options['scopefunc'] = get_scopefunc()
    return SQLAlchemy(app, session_options=session_options)
예제 #5
0
 def create_database(self):
     self.db.session = self.db.create_scoped_session({
         'scopefunc': get_scopefunc(),
     })
     self.db.create_all()