Pyodbc Error Data source name not found and no default driver specified – SQLDriverConnect – ODBC Driver Manager

Pyodbc Error Data source name not found and no default driver specified – SQLDriverConnect – ODBC Driver Manager is an error which occurs because of a mismatch between 64-bit Python and 32-bit ODBC Driver on Windows and sometimes the error might occur for other reasons.

In the blog post I attempt to explain why this error takes place and how you can solve it, I will also add other solutions that could solve the error if possible.

Exploring the Pyodbc Error Data source name not found and no default driver specified – SQLDriverConnect – ODBC Driver Manager

This is an error which occurs because of a mismatch between 64-bit Python and 32-bit ODBC Driver on Windows and sometimes the error might occur for other reasons.

Do not mix between errors. Make sure the error message looks like the error message bellow after double checking.

Pyodbc Error Data source name not found-problem-banner

Bellow is a number of tested solutions that I have tried and worked for me.

Solution 1 : Solve the mismatch between 64-bit Python and 32-bit ODBC Driver on Windows

The first solution is to solve the mismatch between 64-bit Python and 32-bit ODBC Driver on Windows.

There is a hidden origin for this error in every windows machine. It is caused by MS Office.

The solution is to Uninstall  and re-install MS Office.

There is this small link on the install dialog which allows you to install the 64-bit version, Click it.

As a result, you will have the 64-bit ODBC driver and your code will connect to the database with no problem at all.

Solution 2 : Correct your connection string

Please, follow this method only if you use an MDB.

The solution is to Correct your connection string using the following steps :

First, navigate to Control Panel and select Administrative Tools then click on Data Source and then add the DSN file.

Select “Microsoft Access Driver (*.mdb) and continue.

Choose a location and save the .dsn file to it. Now, locate the saved .dsn file and use Notepad to open it.

You will have a list of expressions that you can convert to this

Pyodbc Error Data source name not found-problem-banner-1

I hope this method has solved your problem, thank you for reading this entire blog post.

If the solutions above helped you, consider supporting us on Kofi, any help is appreciated.

Summing-up : 

That is it guys, this is the end of this article aka guide, I hope you found it useful in solving the problem Pyodbc Error Data source name not found , make sure to support our work on Kofi, you do not have to but hey you can donate to the team.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/