Python flask_script 模块,prompt_bool() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用flask_script.prompt_bool()

项目:ara    作者:openstack    | 项目源码 | 文件源码
def dropall():
    """ Drops all database tables """

    if prompt_bool('Are you sure ? You will lose all your data !'):
        db.drop_all()
项目:web_develop    作者:dongweiming    | 项目源码 | 文件源码
def dropdb():
    if prompt_bool(
            'Are you sure you want to lose all your data'):
        db.drop_all()
项目:albionmarket-backend    作者:Regner    | 项目源码 | 文件源码
def run(self):
        if prompt_bool('Are you sure you want to lose all your data!?'):
            extensions.db.drop_all()
项目:mybookshelf2    作者:izderadicka    | 项目源码 | 文件源码
def migrate_tables():
    import psycopg2
    print('This will migrate database to latest schema, you are advised to backup database before running this command')
    if prompt_bool('Do you want to continue?'):
        mdir = os.path.join(SQL_DIR, 'migration')
        version_obj=model.Version.query.one_or_none()

        if not version_obj:
                version_obj=model.Version(version=0, version_id=1)
                db.session.add(version_obj)
        old_version = version_obj.version
        if old_version == db_version:
            print('DB is at correct version %d'% old_version)
        scripts = []
        for script in os.listdir(mdir):
            m=re.match(r'v(\d+)\.sql', script)
            if m:
                version = int(m.group(1))
                if version <= db_version and version > old_version:
                    scripts.append((version, os.path.join(mdir,script)))

        scripts.sort()
        connection = psycopg2.connect(database=settings.DB_NAME,
                                      user = settings.DB_USER,
                                      password = settings.DB_PASSWORD,
                                      host = settings.DB_HOST,
                                      port = settings.DB_PORT)
        connection.autocommit = True
        #connection = db.engine.raw_connection()  # @UndefinedVariable
        try:
            c = connection.cursor()
            for v,fname in scripts:
                script = open(fname, 'rt', encoding='utf-8-sig').read()
                print('Upgrading database to version %d'% v)
                res = c.execute(script)
                version_obj.version = v
                db.session.commit()
                #connection.commit()
        finally:
            connection.close()
项目:mybookshelf2    作者:izderadicka    | 项目源码 | 文件源码
def drop_tables():
    if prompt_bool('Are you REALLY sure? You will loose all data!'):
        db.drop_all()
项目:infosec_mentors_project    作者:andMYhacks    | 项目源码 | 文件源码
def dropdb():
    if prompt_bool(
        "Are you sure you want to drop the database?"):
        db.drop_all()
        print "Database has been dropped"
项目:ara-archive    作者:dmsimard    | 项目源码 | 文件源码
def dropall():
    """ Drops all database tables """

    if prompt_bool('Are you sure ? You will lose all your data !'):
        db.drop_all()
项目:memesocial    作者:mohamed-aziz    | 项目源码 | 文件源码
def dropdb():
    if prompt_bool("Are you sure you wanna drop the database ?"):
        memesocial.db.drop_tables(
            memesocial.all_tables
        )
项目:research-eGrader    作者:openstax    | 项目源码 | 文件源码
def drop_db():
    if prompt_bool(
            'Are you sure you want to lose all your data for {0} ? \nThis is process is not reversible'.format(
                app.config['SQLALCHEMY_DATABASE_URI'].split('@')[1])
    ):
        db.drop_all()
        db.session.commit()
        print('Database has been dropped')
项目:research-eGrader    作者:openstax    | 项目源码 | 文件源码
def reset_db():
    if prompt_bool(
            'Are you sure you want to lose all your data for {0}'.format(
                app.config['SQLALCHEMY_DATABASE_URI'].split('@')[1])
    ):
        from alembic.command import downgrade, upgrade
        from alembic.config import Config as AlembicConfig
        config = AlembicConfig('alembic.ini')
        downgrade(config, 'base')
        upgrade(config, 'head')
        print('Database has been reset')