Error 28000: Login failed for user DOMAIN\\user with pyodbc

后端 未结 8 1425
慢半拍i
慢半拍i 2020-12-06 05:00

I am trying to use Python to connect to a SQL database by using Window authentication. I looked at some of the posts here (e.g., here), but the suggested methods didn\'t see

8条回答
  •  一向
    一向 (楼主)
    2020-12-06 05:39

    The first option works if your credentials have been stored using the command prompt. The other option is giving the credentials (UId, Psw) in the connection.

    The following worked for me:

    conn = pyodbc.connect('DRIVER={SQL Server};SERVER=yourServer;DATABASE=yourDatabase;UID=yourUsername;PWD=yourPassword')
    

提交回复
热议问题