Пример #1
0
    def run(cls, **kwargs):
        dummy_app = Flask(__name__)
        dummy_app.config.from_object('settings')

        import pokr.models
        from utils.login import init_db; init_db(dummy_app)

        Base.metadata.create_all(bind=engine)
Пример #2
0
    def run(cls, **kwargs):
        dummy_app = Flask(__name__)
        dummy_app.config.from_object('settings')

        import pokr.models
        from utils.login import init_db
        init_db(dummy_app)

        Base.metadata.create_all(bind=engine)
Пример #3
0
def init_db(app, login=True):
    if not is_alembic_head():
        raise Exception('alembic is not on the head')

    if login:
        from utils.login import init_db; init_db(app)

    @app.teardown_request
    def shutdown_session(exception=None):
        db_session.remove()
Пример #4
0
def init_db(app):
    if not is_alembic_head():
        raise Exception('alembic is not on the head')

    # import all modules here that might define models so that
    # they will be registered properly on the metadata.  Otherwise
    # you will have to import them first before calling init_db()
    import models
    from utils.login import init_db; init_db(app)

    Base.metadata.create_all(bind=engine)

    @app.teardown_request
    def shutdown_session(exception=None):
        db_session.remove()