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

Python连接Azure Synapse数据库遇40532登录失败错误求解决

Python连接Azure Synapse数据库失败(错误码40532)

已通过Azure Data Studio正常访问Azure Synapse数据库,但使用Python的pyodbc库连接时失败,报错信息如下:

Error: ('HY000', '[HY000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open server "iberdrola.es" requested by the login. The login failed. (40532) (SQLDriverConnect); [HY000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open server "iberdrola.es" requested by the login. The login failed. (40532)')

使用的Python代码如下(敏感信息已隐去):

import pyodbc

server = '*sql.azuresynapse.net'
database = 'D**l'
username = '***'
password = '***'
driver= '{ODBC Driver 13 for SQL Server}'

connection_string = f'DRIVER={driver};SERVER={server};DATABASE={database};UID={username};PWD={password}'

with pyodbc.connect(connection_string) as conn:
    with conn.cursor() as cursor:
        cursor.execute("SELECT TOP 10 * FROM ***")
        row = cursor.fetchone()
        while row:
            print (str(row[0]) + " " + str(row[1]))
            row = cursor.fetchone()

已知信息:

  • 代码中使用的用户名、密码与Azure Data Studio中验证有效的凭据完全一致
  • 本地已安装ODBC Driver 13 for SQL Server

请问连接失败的原因是什么?如何实现Python与该Azure Synapse数据库的正常连接?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 11:47:05