pgmigrate.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:pgmigrate 作者: yandex 项目源码 文件源码
def _is_initialized(cursor):
    """
    Check that database is initialized
    """
    cursor.execute('SELECT EXISTS(SELECT 1 FROM '
                   'information_schema.tables '
                   'WHERE table_schema = %s '
                   'AND table_name = %s)',
                   ('public', 'schema_version'))
    table_exists = cursor.fetchone()[0]

    if not table_exists:
        return False

    cursor.execute('SELECT * from public.schema_version limit 1')

    colnames = [desc[0] for desc in cursor.description]

    if colnames != REF_COLUMNS:
        raise MalformedSchema(
            'Table schema_version has unexpected '
            'structure: {struct}'.format(struct='|'.join(colnames)))

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号