0

I am looking for a solution in the internet, found a lot of proposed solutions but no one worked for me.

That is my situation :

My code is :

import pyodbc

conn = pyodbc.connect(
    r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\User\Documents\MonCommerce.accdb;')
cursor = conn.cursor()
cursor.execute('select * from client')

for row in cursor.fetchall():
    print(row)

The error is (in french) :

conn = pyodbc.connect(
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][Gestionnaire de pilotes ODBC] Source de données introuvable et nom de pilote non spécifié (0) (SQLDriverConnect)')

It means :

ODBC driver error. Untraceable data source and driver name not specified
  • My computer has Windows 7 Profesional SP1 64bit,
  • My Python is 3.8.2 64bit.
  • I am writing my code into PyCharm 2019.3.4 Community Edition,
  • My database is a Microsoft Access 2007
  • In Windows directory, I have both System32 and SysWOW64 directories.

The driver "Microsoft Access Driver (*.mdb, *.accdb)" is located into SysWOW64\odbcad32.exe. How the connection string did not find it ?

I have installed Python from the executable : python-3.8.2-amd64.exe, but when run the command "python" in the PyCharm Terminal, it gives me :

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32

How it can be win32 ?

Parfait
  • 104,375
  • 17
  • 94
  • 125
D. O.
  • 616
  • 1
  • 11
  • 25
  • EDIT: I can't get this markup to work, but have you checked that Python sees the drivers correctly? It's explained on this page https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-Microsoft-Access – oittaa Apr 14 '20 at 16:48
  • You're using 64-bit Python, and Access 2007 which only has a 32-bit version. They can't work together because of that. Get a different version of Access or a different version of Python – Erik A Apr 14 '20 at 17:01
  • Check available installed drivers with `pyodbc.drivers()`. If it is the familiar 32-bit/64-bit issue, one alternative, too, is downgrade `.accdb` to `.mdb`. – Parfait Apr 14 '20 at 17:27
  • @Erik A, why my question is marked as duplicated ? My problem is not the same in the question you have answered. – D. O. Apr 14 '20 at 18:56
  • It is exactly the same. If you had translated it properly, you'd get the same error, and the cause is the same (bitness mismatch) – Erik A Apr 14 '20 at 19:00
  • In my case, I find an answer here https://datasavvy.me/2017/07/20/installing-the-microsoft-ace-oledb-12-0-provider-for-both-64-bit-and-32-bit-processing/. Instead to instal the Access databse engine 2016 by clicking on the file into a filedialog, It is recommanded to run it in command line with quiet option : AccessDatabaseEngine_X64.exe /quiet. If the version is 2010, use /passive in place of /quiet. Now, the Access driver is installed in the odbc inside System32 directory and Python recognize it. My code work now, I can see the data displayed – D. O. Apr 14 '20 at 19:03
  • Regardless, you should consider upgrading your software and OS since [Office 2007](https://learn.microsoft.com/en-us/deployoffice/office-2007-end-support-roadmap) reached its end of support in October 2017 and [Windows 7](https://support.microsoft.com/en-us/help/4057281/windows-7-support-ended-on-january-14-2020) reached its end of support in January 2020. – Parfait Apr 14 '20 at 19:18
  • @Parfait Yes Parfait you are right. But, i am just learning Python in an old PC at home. Thank you every one. – D. O. Apr 14 '20 at 19:27

0 Answers0