0

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.