Reputation: 1200
I am trying to connect to MSSQL server using pyodbc. I can connect to the server and query it using the basic authentication mode as:
connection = pyodbc.connect("DRIVER={Easysoft ODBC-SQL Server};SERVER=192.168.2.119;DATABASE=dbame;UID=**;PWD=****")
Connection to MSSQL can also be done using Windows Authentication where it takes the parameters
DOMAIN
USERNAME
PASSWORD
I don't know how to use this sort of credential from pyodbc to connect to the MSSQL Server.
Furthermore, the ODBC driver I am using (Easysoft ODBC-SQL Server) needs licensing. Don't we get such drivers for free?
Upvotes: 0
Views: 10748
Reputation: 631
connection = pyodbc.connect("DRIVER={Easysoft ODBC-SQL Server};SERVER=192.168.2.119;DATABASE=dbame;UID=;PWD=**")
The string part of the connection is what is known as a DSN-Less connection so you can pass in any of the attributes required for example :-
connection = pyodbc.connect("DRIVER={Easysoft ODBC-SQL Server};SERVER=192.168.2.119;DATABASE=dbame;UID=MyWindowsUserName;PWD=MyPassword;Trusted_Domain=MyWindowsDomainName;Trusted_Connection=1")
Trusted_Connection = 1 tells the Easysoft driver that you intend to use the Trusted_Domain, user ( UID ) and password ( PWD ) to login to SQL Server.
For a full list of all the attributes available within the Easysoft ODBC-SQL Server Driver please read the Attributes section of the manual.
Upvotes: 1
Reputation: 1143
The Easysoft SQL Server driver parameters to use NTLM authentication are
Trusted_Domain=<domain name>
NTLMv2=Yes|No
Trusted_Connection=Yes|No
And UID, PWD as usual.
NTLM can also be triggered simply using a UID that looks like
DOMAIN\USER
If you want to use Kerberous, the following can be set
ServerSPN=SPN
Its all the the user guide for the driver
Upvotes: 1