python - 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?
解决方案
使用try
/怎么样except
?
try:
# connect to the DB
except MySQLConnectionError:
pass
# continue script
推荐阅读
- python - numpy 可以对字典对象列表进行排序,还是 pandas 数据框操作是我唯一的选择?
- python - 遍历字符串列表:错误消息
- python - 打开电子邮件时触发Python Outlook win32事件
- python - 如何使用 ruamel.yaml 读取多个 yaml 定义
- pandas - 从包含所有行的数据框中选择两组列
- flutter - 在颤动中使用索引更改文本的颜色部分
- visual-studio - Visual Studio 2019 中的 ThreadSanitizer
- html - Tailwind css 弹出窗口显示在图标下方
- sql - SQL ORACLE 12.1.0.2.0 JSON_EXISTS/VALUE
- .net-core - 使用配置更改 .net 核心应用程序的引用 dll