Pyodbc error pyodbc.interfaceerror [How to Solve]

connection = pyodbc.connect(r'Driver={SQL Server Native Client 11.0};Server=...;Database=...;Trusted_Connection=yes;')

When using pyodbc to connect the SQL database, the above code runs OK on the development machine, but it runs error on other computers. The error information is as follows:

pyodbc.InterfaceError: (‘IM002’, ‘[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)’)。

After checking all afternoon, I found that there was an error in the driver parameter. Just modify it to driver = {SQL Server}. The reason is that SQL server is a SQL Server with complete functions. SQL native client is a client tool for users. It is only used to operate the window of database service. 11.0 may not be configured on other computers. The SQL server installed on the development machine is 2012, while the other machines are 2008.


Similar Posts: