Connecting to MS SQL Server using python on linux with 'Windows Credentials'

后端 未结 5 1821
天涯浪人
天涯浪人 2021-02-04 15:27

Is there any way to connect to an MS SQL Server database with python on linux using Windows Domain Credentials?

I can connect perfectly fine from my windows machine usin

5条回答
  •  心在旅途
    2021-02-04 15:52

    Probably a bit too late to help you out - but I encountered the same issue. At the time of writing, the latest version of pyodbc allows me to login with windows credentials. Just leave the UID field blank in your connection string like so:

    cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=myserverinstance;DATABASE=mydatabase;UID=;PWD=mypassword')
    

    Now this is using your existing windows credentials when you're logged on... not sure how to specify any arb windows domain credentials...

提交回复
热议问题