migrations.py 文件源码

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

项目:django-north 作者: peopledoc 项目源码 文件源码
def get_current_version_from_comment():
    """
    Return the current version of the database, from django_site comment.
    Return None if the table django_site does not exist (schema not inited).
    """
    with connection.cursor() as cursor:
        try:
            cursor.execute(
                "SELECT obj_description('django_site'::regclass, 'pg_class');")
        except ProgrammingError:
            # table does not exist ?
            return None

        row = cursor.fetchone()
        comment = row[0]

    # no comment
    if comment is None:
        raise DBException('No comment found on django_site.')

    # parse comment
    if 'version ' not in comment:
        raise DBException("No version found in django_site's comment.")
    return comment.replace('version ', '').strip()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号