0

Im trying to connect my Python Jupyter notebook with my local SQL Server instance. I am stuck at setting up the connection string. Hope I am not missing something obvious. I know the general string is:

DRIVER%3D%7BODBC+Driver+13+for+SQL+Server%7D%3BSERVER%3Dlocalhost%3BPORT%3D1433%3BDATABASE%3Dnb-database%3BUID%3Dnb-user%3BPWD%3Dnb-password%3B

Which is fine, except that I am using Windows Authentication so that, as I am logged into Windows, I don't need a password. What should I enter in the password part then?

MSIS
  • 157
  • 1
  • 8
  • 1
    Does this answer your question? [Connecting to MS SQL Server with Windows Authentication using Python?](https://stackoverflow.com/questions/16515420/connecting-to-ms-sql-server-with-windows-authentication-using-python) – Charlieface Jan 15 '21 at 02:47
  • 1
    Don't pass a username and password, they are ignored. If you need a particular Windows login, you must impersonate client-side – Charlieface Jan 15 '21 at 02:48
  • @Charlieface: Thank you, will try. Do you know where Windows10 stores its connection strings? Maybe I can check there too. EDIT: And using " Trusted Connection = Yes" instead of password, I guess is what you meant by impersonating client side? – MSIS Jan 15 '21 at 03:22
  • Thanks, but the link seems to have sidestepped the issue of entering a password, at least as far as I can tell. – MSIS Jan 15 '21 at 03:33
  • 2
    Windows 10 does not store connection strings or passwords. When you connect with Trusted Connection, the ODBC driver passes the current Windows login's Kerberos ticket (for AD) or NTLM hash (non AD), from when the user logged in to the PC. So it is based on the existing logged in **Windows** user. If you want another user, you must do Windows login impersonation, which is a whole new kettle of fish. – Charlieface Jan 15 '21 at 03:35

0 Answers0