Connecting to MS SQL Server with Windows Authentication using Python?

后端 未结 3 1876
一整个雨季
一整个雨季 2020-12-01 00:14

How do I connect MS SQL Server using Windows Authentication, with the pyodbc library?

I can connect via MS Access and SQL Server Management Studio, but cannot get a

3条回答
  •  囚心锁ツ
    2020-12-01 00:41

    Windows Authentication can also be specified using a keyword. Nothing functionally different from the accepted answer, I think it makes code formatting a bit easier:

    cnxn = connect(driver='{SQL Server}', server='localhost', database='test',               
                   trusted_connection='yes')
    

提交回复
热议问题