python,flask,报MySQLdb.OperationalError: (2006, ‘‘)

关于flask-mysqldb库的使用说明中提到,无需显示关闭连接,只需删除mysql.connection.close()即可。
Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: 2025-10-27 17:37:33,118:WARNING:superset.views.error_handling:SupersetErrorsException Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: Traceback (most recent call last): Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/commands/database/test_connection.py", line 176, in run Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: raise DBAPIError(ex_str or None, None, None) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: sqlalchemy.exc.DBAPIError: (builtins.NoneType) None Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: [SQL: (MySQLdb.OperationalError) (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: (Background on this error at: https://sqlalche.me/e/14/e3q8)] Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: (Background on this error at: https://sqlalche.me/e/14/dbapi) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: The above exception was the direct cause of the following exception: Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: Traceback (most recent call last): Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/venv/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: rv = self.dispatch_request() Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/venv/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/venv/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: return f(self, *args, **kwargs) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/views/base_api.py", line 120, in wraps Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: duration, response = time_function(f, self, *args, **kwargs) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/utils/core.py", line 1369, in time_function Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: response = func(*args, **kwargs) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/utils/log.py", line 304, in wrapper Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: value = f(*args, **kwargs) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/views/base_api.py", line 92, in wraps Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: return f(self, *args, **kwargs) Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/databases/api.py", line 1204, in test_connection Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: TestConnectionDatabaseCommand(item).run() Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: File "/home/gapinyc/superset/superset/commands/database/test_connection.py", line 205, in run Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: raise SupersetErrorsException(errors) from ex Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: superset.exceptions.SupersetErrorsException: [SupersetError(message='(builtins.NoneType) None\n[SQL: (MySQLdb.OperationalError) (2002, "Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysqld.sock\' (2)")\n(Background on this error at: https://sqlalche.me/e/14/e3q8)]\n(Background on this error at: https://sqlalche.me/e/14/dbapi)', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'MySQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})] Oct 27 17:37:33 DESKTOP-9QS7RL5 start_superset.sh[3866]: 127.0.0.1 - - [27/Oct/2025:17:37:33 +0800] "POST /api/v1/database/test_connection/ HTTP/1.1" 500 507 "http://192.168.110.204/superset/welcome/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0"
10-28
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值