checks.py 文件源码

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

项目:python-dockerflow 作者: mozilla-services 项目源码 文件源码
def check_database_connected(app_configs, **kwargs):
    """
    A Django check to see if connecting to the configured default
    database backend succeeds.
    """
    errors = []

    try:
        connection.ensure_connection()
    except OperationalError as e:
        msg = 'Could not connect to database: {!s}'.format(e)
        errors.append(checks.Error(msg, id=ERROR_CANNOT_CONNECT_DATABASE))
    except ImproperlyConfigured as e:
        msg = 'Datbase misconfigured: "{!s}"'.format(e)
        errors.append(checks.Error(msg, id=ERROR_MISCONFIGURED_DATABASE))
    else:
        if not connection.is_usable():
            errors.append(checks.Error('Database connection is not usable',
                                       id=ERROR_UNUSABLE_DATABASE))

    return errors
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号