python类prompt_bool()的实例源码

manage.py 文件源码 项目:ara 作者: openstack 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def dropall():
    """ Drops all database tables """

    if prompt_bool('Are you sure ? You will lose all your data !'):
        db.drop_all()
manage.py 文件源码 项目:web_develop 作者: dongweiming 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def dropdb():
    if prompt_bool(
            'Are you sure you want to lose all your data'):
        db.drop_all()
drop_db.py 文件源码 项目:albionmarket-backend 作者: Regner 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def run(self):
        if prompt_bool('Are you sure you want to lose all your data!?'):
            extensions.db.drop_all()
manage.py 文件源码 项目:mybookshelf2 作者: izderadicka 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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()
manage.py 文件源码 项目:mybookshelf2 作者: izderadicka 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def drop_tables():
    if prompt_bool('Are you REALLY sure? You will loose all data!'):
        db.drop_all()
manage.py 文件源码 项目:infosec_mentors_project 作者: andMYhacks 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def dropdb():
    if prompt_bool(
        "Are you sure you want to drop the database?"):
        db.drop_all()
        print "Database has been dropped"
manage.py 文件源码 项目:ara-archive 作者: dmsimard 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def dropall():
    """ Drops all database tables """

    if prompt_bool('Are you sure ? You will lose all your data !'):
        db.drop_all()
manage.py 文件源码 项目:memesocial 作者: mohamed-aziz 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def dropdb():
    if prompt_bool("Are you sure you wanna drop the database ?"):
        memesocial.db.drop_tables(
            memesocial.all_tables
        )
manage.py 文件源码 项目:research-eGrader 作者: openstax 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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')
manage.py 文件源码 项目:research-eGrader 作者: openstax 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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')


问题


面经


文章

微信
公众号

扫码关注公众号