当前位置: 首页>>代码示例>>Python>>正文


Python migrate.SqliteMigrator方法代码示例

本文整理汇总了Python中playhouse.migrate.SqliteMigrator方法的典型用法代码示例。如果您正苦于以下问题:Python migrate.SqliteMigrator方法的具体用法?Python migrate.SqliteMigrator怎么用?Python migrate.SqliteMigrator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playhouse.migrate的用法示例。


在下文中一共展示了migrate.SqliteMigrator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_sqlite

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import SqliteMigrator [as 别名]
def init_sqlite(url):
    global DB

    dbfile = os.path.join("/", *url.path.split("/"))
    dirname = os.path.dirname(dbfile)

    log.info('Opening sqlite database: %s', dbfile)

    if not os.path.exists(dirname):
        os.makedirs(dirname)

    DB.initialize(SqliteDatabase(dbfile))
    log.info("Database initialized as '%s'. Checking migrations...", dbfile)
    return DB, SqliteMigrator(DB) 
开发者ID:mosquito,项目名称:pypi-server,代码行数:16,代码来源:__init__.py

示例2: setup_db

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import SqliteMigrator [as 别名]
def setup_db():
    global home, database
    database_url = config.get("db", "sqlite:///diffengine.db")
    logging.debug("connecting to db %s", database_url)
    database_handler = connect(database_url)
    database.initialize(database_handler)
    database.connect()
    database.create_tables([Feed, Entry, FeedEntry, EntryVersion, Diff], safe=True)

    if isinstance(database_handler, SqliteDatabase):
        try:
            migrator = SqliteMigrator(database_handler)
            migrate(migrator.add_index("entryversion", ("url",), False))
        except OperationalError as e:
            logging.debug(e) 
开发者ID:DocNow,项目名称:diffengine,代码行数:17,代码来源:__init__.py

示例3: db_upgrade

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import SqliteMigrator [as 别名]
def db_upgrade(old_version):
    migrator = SqliteMigrator(_db)
    if old_version < 2:
        User_login.create_table()
        migrate(
            migrator.add_column('clan_member', 'remaining_status',
                                TextField(null=True)),
            migrator.add_column('clan_challenge', 'message',
                                TextField(null=True)),
            migrator.add_column('clan_group', 'boss_lock_type',
                                IntegerField(default=0)),
            migrator.drop_column('user', 'last_save_slot'),
        )
    if old_version < 3:
        migrate(
            migrator.drop_column('user', 'auth_cookie'),
            migrator.drop_column('user', 'auth_cookie_expire_time'),
        )
    if old_version < 4:
        migrate(
            migrator.add_column('user', 'deleted',
                                BooleanField(default=False)),
        )
    if old_version < 5:
        migrate(
            migrator.add_column('user', 'must_change_password',
                                BooleanField(default=True)),
        )
    if old_version < 6:
        User.update({User.authority_group: 1}).where(
            User.authority_group == 2).execute()
    if old_version < 7:
        migrate(
            migrator.drop_column('clan_challenge', 'comment'),
            migrator.add_column('clan_challenge', 'behalf',
                                IntegerField(null=True)),
            migrator.drop_column('clan_subscribe', 'comment'),
            migrator.add_column('clan_subscribe', 'message',
                                TextField(null=True)),
            migrator.add_column('clan_group', 'apikey',
                                CharField(max_length=16, default=rand_string)),
        )
    if old_version < 8:
        migrate(
            migrator.add_column('clan_group', 'deleted',
                                BooleanField(default=False)),
            migrator.add_column('clan_group', 'battle_id',
                                IntegerField(default=0)),
            migrator.add_column('clan_challenge', 'bid',
                                IntegerField(default=0)),
            migrator.add_index('clan_challenge', ('bid', 'gid'), False)
        )
    if old_version < 9:
        migrate(
            migrator.add_index('clan_member', ('qqid',), False)
        )

    DB_schema.replace(key='version', value=str(_version)).execute() 
开发者ID:yuudi,项目名称:yobot,代码行数:60,代码来源:ybdata.py


注:本文中的playhouse.migrate.SqliteMigrator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。