1
votes

I have successfully connected to this database many times before, but just now I have encountered this error:

pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

This is my code:

pathofprog = os.path.dirname(__file__) #Locates the path of the program
dblocation = os.path.join(pathofprog, "Database.accdb") #Locates the database at this path
db = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=%s;'%dblocation) #Connects to the database
dbcursor = db.cursor() #Creates the database cursor

Any help would be much appreciated

1
what do you get when you print(pathofprog) ? - Niharika Bitra
Check the list returned by pyodbc.drivers() to see if the Microsoft Access Driver is available to your app. - Gord Thompson
Any recent changes to Python or Windows or Access or other ODBC drivers? Are you sure everything's still 32-bit (or everything's still 64-bit)? Reinstalling the redistributable Access kit (either or both -- 32-bit and/or 64-bit) may be a quick solution. - TallTed
How can I check everything is 64-bit or 32-bit, I guess we can't install 32-bit modules on 64-bit python. uhmm - Fernando V

1 Answers

0
votes

I follow Gord Thompson's advice in comments to question and printed the list of drivers on my system and resolved it by changing the driver from:

DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}

to

DRIVER={Microsoft Access Driver (*.mdb)

Hope that help, Warren