import pyodbc connection = pyodbc.connect('Driver = {SQL Server};Server=SIWSQL43A\SIMSSPROD43A;' 'Database=CSM_reporting;Trusted_Connection=yes;')
Error:
connection = pyodbc.connect('Driver = {SQL Server};Server=SIWSQL43A\SIMSSPROD43A;' pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
You can check the drivers which are installed on your system by going to the ODBC Data Source Administrator. To open it, press ⊞ Win + R , and type in: odbcad32.exe . Then check the tab Drivers for installed drivers. The Name column indicates the exact name you should use in your connection string or DSN.
pyODBC uses the Microsoft ODBC driver for SQL Server.
Do not put a space after the Driver
keyword in the connection string.
This fails on Windows ...
conn_str = ( r'DRIVER = {SQL Server};' r'SERVER=(local)\SQLEXPRESS;' r'DATABASE=myDb;' r'Trusted_Connection=yes;' ) cnxn = pyodbc.connect(conn_str)
... but this works:
conn_str = ( r'DRIVER={SQL Server};' r'SERVER=(local)\SQLEXPRESS;' r'DATABASE=myDb;' r'Trusted_Connection=yes;' ) cnxn = pyodbc.connect(conn_str)
I've met same problem and fixed it changing connection string like below. Write
'DRIVER={ODBC Driver 13 for SQL Server}'
instead of
'DRIVER={SQL Server}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With