You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Superset连接Azure Synapse Data Warehouse?连接字符串报错求助

解决Superset连接Azure Synapse Data Warehouse的连接字符串问题

问题概述

已通过Python pyodbc驱动成功连接Azure Synapse Data Warehouse,但按照Superset官方SQL Server文档配置的连接字符串无法连接,触发事务相关错误。

可用的Python pyodbc连接代码

import pyodbc

conn = pyodbc.connect(
    "DRIVER={ODBC Driver 18 for SQL Server};SERVER=myserver.sql.azuresynapse.net;PORT=1433;DATABASE=mydb;UID=user;PWD=password"
)

原Superset连接字符串(报错)

mssql+pyodbc:///?odbc_connect=DRIVER={ODBC+Driver+18+for+SQL+Server};SERVER=tcp:myserver.sql.azuresynapse.net,1433;DATABASE=mydb;UID=user;PWD=password

报错信息

SupersetError(message="(pyodbc.ProgrammingError) ('42000', '[42000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]111214;An attempt to complete a transaction has failed. No corresponding transaction found. (111214) (SQLEndTran)')
(Background on this error at: http://sqlalche.me/e/13/f405)", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'Azure Synapse', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})] [546536][139917057312512

正确的Superset连接字符串

mssql+pyodbc:///?odbc_connect=DRIVER={ODBC+Driver+18+for+SQL+Server};SERVER=myserver.sql.azuresynapse.net;PORT=1433;DATABASE=mydb;UID=user;PWD=password;autocommit=True

关键修改说明

  • 对齐本地成功的pyodbc写法:移除SERVER地址前的tcp:前缀,改用PORT=1433单独指定端口
  • 添加autocommit=True:Azure Synapse的事务处理逻辑与常规SQL Server不同,开启自动提交可解决"找不到对应事务"的报错
  • 确保ODBC参数的URL编码正确(如驱动名称中的空格用+替换)

内容的提问来源于stack exchange,提问作者yu kang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:03:31