pyodbc-不可信域

时间:2019-07-12 23:56:17

标签: python sql sql-server pyodbc

上下文:我正在尝试使用Python查询远程服务器上SQL Server 2017中的某些数据。请遵循此处的建议:https://www.youtube.com/watch?v=aF552bMEcO4

问题:有人知道如何解决以下问题?当我从远程服务器查询时,我假设将连接设置为“可信”,而实际上我已登录VPN即可解决此问题。我是否需要使用其他身份验证方法,而不是“集成身份验证”?

我在Powershell中提出了此错误:

Traceback (most recent call last):
  File "pyodbc_test.py", line 13, in <module>
    "Driver={SQL Server Native Client 11.0};"
pyodbc.InterfaceError: ('28000', '[28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication. (18452) (SQLDriverConnect); [28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication. (18452)')

这是我要执行的Python:

import pyodbc

def read(connection):
    print("Read")
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM [RDW_DIV29].[dbo].[Catalog]")
    for row in cursor:
        print(f'row = {row}')
    print()

connection = pyodbc.connect(
    "Driver={SQL Server Native Client 11.0};"
    "Server=REDACTED;"
    "Database=REDACTED;"
    "Trusted_Connection=yes;"
)

read(connection)

connection.close()

0 个答案:

没有答案