Using an Access database (.mdb) with Python on Ubuntu

10,878

From what I know this driver "Microsoft Access Driver (*.mdb)" is only available on a Microsoft host, since you are on ubuntu, it won't work.

Share:
10,878
mythander889
Author by

mythander889

Updated on June 14, 2022

Comments

  • mythander889
    mythander889 almost 2 years

    I'm trying to use pyodbc to access a .mdb on Ubuntu. I've based my progress so far on this link

    Query crashes MS Access

    I have installed pyodbc, unixodbc, and unixodbc-dev

    My code looks like this:

    import csv
    import pyodbc
    
    MDB = 'URY.mdb'
    DRV ='Microsoft Access Driver (*.mdb)'
    PWD = 'pass'
    
    conn = pyodbc.connect('DRIVER=%s;DBQ=%s;PWD=%s' % (DRV,MDB,PWD))
    curs = conn.cursor()
    

    When I run it, I receive this error message:

    Traceback (most recent call last):
      File "mdbscraper.py", line 8, in <module>
        conn = pyodbc.connect('DRIVER=%s;DBQ=%s;PWD=%s' % (DRV,MDB,PWD))
    pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found,         and no default driver specified (0) (SQLDriverConnect)')
    

    Does anyone have any ideas? Any help would be very much appreciated

    Thank you!