簡體   English   中英

使用 Python 連接到 SQL 服務器時,用戶 '' 登錄失敗

[英]Login failed for user '' when connecting to SQL Server using Python

我正在嘗試使用以下代碼使用 Python 連接到 SQL 服務器數據庫:

conn = pyodbc.connect(
                  r'Driver={SQL Server Native Client 11.0};'    
                  r'Server=12345.dcd_ba.weatherton.com;'
                  r'Database=Dentrix;'
                  r'Trusted_Connection=no;'
                  r'Integrated security=false;'
                  r'username=fred;'
                  r'password=test;'
                 )
return conn

但我收到此錯誤:

pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]用戶''登錄失敗。(18456) (SQLDriverConnect); [28000] [Microsoft][SQL Server Native Client 11.0]無效的連接字符串屬性 (0);[28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]用戶 '' 登錄失敗。(18456);[28000] [Microsoft][SQL Server Native客戶端 11.0]無效的連接字符串屬性 (0)")

根據Using Connection String Keywords with SQL Server Native Client看來您需要使用UID而不是username

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM