首页 > 解决方案 > Django ignore mysql connection error

问题描述

How do I "ignore" or "pass" on an MySQL connection error using Django?

Right now when my app tries to connect to the Database and the Database is offline (for whatever reason (update etc)) the script just throws the error but I want the script to continue running even if there is no database connection.

Is this possible?

标签: pythonmysqldjango

解决方案


使用try/怎么样except

try:
    # connect to the DB
except MySQLConnectionError:
    pass
# continue script

推荐阅读