Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot open .mdb file (MS Access) with mdbtools and pyodbc (Ubuntu) - drivers not found #384

Closed
average-everyman opened this issue Apr 13, 2022 · 1 comment

Comments

@average-everyman
Copy link

Hello,
I am not able to open an .mdb file on Ubuntu. I am attempting to do that with pyodbc and mdbtools. This is how I installed it:

sudo apt install python3-dev unixodbc-dev
sudo apt install mdbtools
pip install --user pyodbc

and this is the error I get when running the py script:

(pyodbc.Error) ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'Microsoft Access Driver (*.mdb, *.accdb)' : file not found (0) (SQLDriverConnect)")

So pyodbc cannot find the proper driver I guess.
this:

import pyodbc
pyodbc.drivers()

returns an empty list.

I assumed the required driver is installed when mdbtools is installed - or am I wrong?
How to make it work?

Thank you for your answers.

@fladi
Copy link

fladi commented Jul 25, 2022

You have to install the odbc-mdbtools package which contains the actual ODBC driver shared object file (libmdbodbc.so).

apt install odbc-mdbtools

This should add a driver stanza to /etc/odbcinst.ini:

[MDBTools]
Description=MDBTools Driver
Driver=libmdbodbc.so
Setup=libmdbodbc.so
FileUsage=1
UsageCount=1

Now you can use pyodbc to load the MDB file:

import pyodbc
db = pyodbc.connect("Driver=MDBTools;DBQ=path/to/file.mdb")
print(db.cursor().tables())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants