1

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

TallTed
  • 9,069
  • 2
  • 22
  • 37
Morgan
  • 71
  • 1
  • 2
  • 8
  • what do you get when you print(pathofprog) ? – Niharika Bitra Feb 11 '19 at 23:01
  • 2
    Check the list returned by `pyodbc.drivers()` to see if the Microsoft Access Driver is available to your app. – Gord Thompson Feb 11 '19 at 23:32
  • 1
    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](https://www.microsoft.com/en-us/download/details.aspx?id=54920) (either or both -- 32-bit and/or 64-bit) may be a quick solution. – TallTed Feb 12 '19 at 00:58
  • 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 Feb 11 '20 at 22:40

1 Answers1

0

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

warrenei
  • 126
  • 3