I'm encountering an issue while attempting to connect to a SQL Server database using the pyodbc library in Python. Here's the relevant code snippet:
import pyodbc
cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=localhost,1443;"
"Database=emp;"
"user=sam;"
"password=xyz@123;"
"Trusted_Connection=yes;")
import pyodbc
cnxn = pyodbc.connect("Driver={SQL Server Native Client 17.0};"
"Server=localhost;"
"Database=emp;"
"user=sam;"
"password=xyz@123;"
"Trusted_Connection=yes;")
Tried both way also installed driver manually from microsoft based on code driver but no solution worked.
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')