pyodbc connection to mdb file - ms-access

I am trying to connect pyodbc to an mdb file. I have searched this site and tried a number of things without success. Here is an overview of my system.
Windows 7 Ultimate Service Pack 1
64 Operating System
Python 3.4.0 installed in C:\Python34\ installed using python-3.4.0.amd64.msi
pyodbc 3.0.7 installed using pyodbc-3.0.7.win-amd64-py3.4.exe
Installed AccessDatabaseEngine.exe 14.0.6119.5000 MS 2007 Office System Driver
Control Panel\All Control Panel Items\Administrative Tools Data Sources (ODBC) set to %windir%\SysWOW64\odbcad32.exe
Permissions in the Registry for my user profile set to Full for Microsoft Access Driver (*.mdb, *.accdb)
The code that I am using is:
import csv, pyodbc
conn=pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=c:\MDBTest\MyTestMdb.mdb;')
The error that I continue to get using a number of variations of the code is:
conn=pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=c:\MDBTest\MyTestMdb.mdb;')
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
Thanks in advance for your help.

You are using a 64-bit version of Python but you have the 32-bit version of the Access Database Engine installed. You either need to
run a 32-bit version of Python, or
remove the 32-bit version of the Access Database Engine and install the 64-bit version (available here).

Related

pyodbc and MS access - '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') [duplicate]

My Softwares:
Python 3.4 -64 bit
PyODBC 64 bit
MS office package Installed (32 bit)
Problem:
Now, I try to access MS Access 2010 installed in my computer using PYODBC. It does not work regardless of what I try. My error is always this:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
I already looked at:
pyodbc and ms access 2010 connection error
Cannot connect to Access DB using pyodbc
It is suggested that it is 32-64 bit problem which I am sure it is. Is there some modification that can be done to make it work without installing 32 bit python and 32 bit pyodbc? I checked this website.Using ODBC (32-bit and 64-bit) on 64-bit Windows which explains about accessing the control panel to modify ODBC connnection and/or drivers. However, I don't know much about windows database connection internals to commence some changes.
Is there something that I can do to make it work?
Is there some modification that can be done to make it work without installing 32 bit python and 32 bit pyodbc?
Not really. If you have 32-bit Office installed then you have the 32-bit version of the Access Database Engine (a.k.a. "ACE"), and only 32-bit applications can use it.
The installer for the 64-bit version of the Access Database Engine will abort if it detects 32-bit Office components. There is a way to force the installer to continue, but that is not recommended because it can apparently break Office.
Bottom Line: The "bitness" of your application must match the "bitness" of the installed Access Database Engine. So, practically speaking, your options are
Use 32-bit Python and pyodbc, or
replace your 32-bit Office with the 64-bit version.

Connect to MS Access MDB file from .netcore 3.1

i'm trying connection to MDB file using .netcore 3.1.
i tried using oledb but it's not working i guess because my pc is windows 10.
i tried using odbc and i'm getting the following error.'ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application'
i have office 365 32 bit installed on my pc.

Missing ACCDB database drivers

Please explain this one to me ....
I am on a x64 bit computer (well, not literally standing on it :) ). And I have Office x64 installed, including x64 Microsoft Access.
Using Access I can open ACCDB and MDB files. yet, if I run the x64 ODBC Drivers component there is NO Microsoft Access Database (*.mdb, *.accdb) driver listed.
The only way I can get it listed is if I install the x64 Access 2013
Runtime. Then it shows up.
Why is it not showing if I have access only installed?
Basically, I am trying to detect if my own executable is going to be able to open the ACCDB database OK. I do that by examining what drivers are installed.
I had the same problem on a 64 bit Windows 10 system with 64 bit Office 2016. I was missing 64 bit ODBC Access drivers. Listing drivers (from Python's pyodbc module) showed only:
'SQL Server'
'PostgreSQL ODBC Driver(ANSI)'
'PostgreSQL ODBC Driver(UNICODE)'
I installed the Microsoft Access Database Engine 2016 Redistributable from Microsoft's site and it came with the extra drivers needed. I could then list:
'SQL Server'
'PostgreSQL ODBC Driver(ANSI)'
'PostgreSQL ODBC Driver(UNICODE)'
'Microsoft Access Driver (*.mdb, *.accdb)'
'Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)'
'Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)'
'Microsoft Access Text Driver (*.txt, *.csv)'
And I was able to query an accdb file using the ODBC drivers from Python.
Downloading from the Microsoft Access Database Engine 2016 Redistributable at https://www.microsoft.com/en-us/download/confirmation.aspx?id=54920 also worked for me. It may go without saying, but I think it's worth noting that if your application/executable uses 32-bit drivers and you download the 64-bit Access Database Engine, the 32-bit application/executable may not recognize the Microsoft Access Database (*.mdb, *.accdb) driver.

Using the correct mySQL ODBC driver in windows

I am trying to connect MS Access with a local mySQL database.
To do this I downloaded the mySQL ODBC connector from the mySQL website and installed it. As I am on a 64-bit system I went for the 64-bit version.
I then discovered when trying to connect Access to mySQL that my installation of Office is actually 32-bit so the driver doesn't work. So I removed the 64-bit ODBC driver and installed the 32-bit one.
Problem is, when I go into control-panel -> Administrative Tools -> Data Sources (ODBC) and try to add a new data source, the only options for the mySQL drivers seem to point to the old directory where the 64-bit drivers were. It then fails as it can't find the dlls with system error 126.
How do I get it to show the 32-bit drivers?
Run the 32-bit manager by running this command:
c:\windows\syswow64\odbcad32.exe
Also you can use RegisterDatabase() function to create connection from your code.
I wrote wrapper function many years ago:
http://5codelines.net/kak-programmno-sozdat-odbc-dsn/.
Just skip russian language and use the code.
Prior to installing the ODBC MySQL driver 5.2.6 you need to install the Microsoft Visual C++ 2010 Redistributable Package for x64 or x86 or both (just search the Microsoft site for these and download from there). Other driver versions may require different versions of this MS VC++ Redist. Package, which can coexist side by side. By default server 2008 R2 comes with the 2008 version, so installing the 2010 is required. Before installing check in Programs and Features if not already installed. Depending on you application it may require the 32 bit or the 64 bit version. Without it you get the system error 126
Then install the drivers:
To install the 32 bit version run as administrator c:\windows\syswow64\odbcad32.exe which is the 32 bit version of "Data Sources (ODBC)"

Database error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I am running SMS Enabler software in a Windows 7 environment. When a message received, the database is not updating and gives the error.
Database error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I also added the required field in Control Panel\All Control Panel Items\Administrative Tools > Data Sources (ODBC) > User DSN
I am using MySQL.
OK.... If test connection succeeds and your app fails then it is probably one of those awkward environment issues..
Things to check -
Have you creates a System DSN or User DSN?
If your application is running as a System Service then it will only able to read System DSNs (not User DSNs)
Was the Driver installed for all users or just the installation user?
I have seen instances where this has affected some drivers...
Use Process Monitor (an excellent tool for tracking down issues like this)
If you haven't used Process Monitor - think of it as a sniffer for; file accesses, registry accesses and network access...
That is - you will be able to determine whether there are any files or registry accesses that are failing or being blocked.
To use SMS Enabler with MySQL you should install MySQL Connector/ODBC 5.1 32-bit. You should install 32-bit version of this connector even if you are on 64 bit Windows. This is because SMS Enabler is a 32-bit software.
Wondering again whether this is a 32/64bit issue?
There are two ODBC administrators on 64bit machines...
c:\Windows\system32\odbcad32.exe === 64bit === Also through Control Panel
c:\Windows\SysWOW64\odbcad32.exe === 32bit
If your application is 32bit then you need a 32bit ODBC Driver and have to create a 32bit ODBC data source.
If your application is 64bit then, similarly, you need a 64bit ODBC Driver and have to create a 64bit ODBC data source.
I am wondering whether your application is 32bit and hence cannot find the 64bit ODBC data source you have created...
(NOTE: all of this is only applicable on 64bit Windows OSs...)