Code in Python
import pyodbc
server = '<SERVER_NAME>.database.windows.net'
database = '<DB_NAME>'
username = '<USER>@<DOMAIN>.com'
password = '<PASSWORD>'
authentication = 'ActiveDirectoryPassword'
driver= '{ODBC Driver 17 for SQL Server}'
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';UID='+username+';Authentication='+authentication+';PWD='+password)
cursor = cnxn.cursor()
cursor.execute("SELECT @@version;")
row = cursor.fetchone()
while row:
print(row[0])
row = cursor.fetchone()
Error Info on RedHat VM (version 7.2)
Traceback (most recent call last):
File "sample.py", line 9, in <module>
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';UID='+username+';Authentication='+authentication+';PWD='+password)
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
The Same piece of Code runs on Windows Machine.
Both have Odbc 17 installed and using 'pyodbc' python library to connect to Database.
Can you please look into this matter ASAP?
Thank You