5

I've been beating my head against this for a few days now. I'm trying to use pyodbc to connect to a Microsoft Access DB, and I can't seem to get the connection string right or something. This is what I'm using:

cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Path\to\file.accdb')

I keep getting the error:

Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')

Even though when I run dataSources() I see:

{'MS Access Database': 'Microsoft Access Driver (*.mdb, *.accdb)', 'dBASE Files': 'Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)', 'Excel Files': 'Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)'}

Is there something I'm severely missing here?

4
  • There is a similar question that may help : stackoverflow.com/questions/3251702/… Commented Dec 28, 2010 at 20:08
  • I'd already found that thread and tried all that it suggests. Still can't seem to get this to work. Commented Dec 28, 2010 at 20:34
  • It's helpful when you post a question after trying other SO solutions to point to them and explain why they didn't solve your problem. Commented Dec 29, 2010 at 1:49
  • I got the same exact error string as before Commented Dec 29, 2010 at 3:45

2 Answers 2

6

This is a 64-bitness problem. I solved it by using 32-bits python and pyodbc.

Sign up to request clarification or add additional context in comments.

Comments

1

Try adding Provider=MSDASQL. It's deprecated but it seems to work OK:

cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};
DBQ=C:\Path\to\file.accdb; Provider=MSDASQL;')

6 Comments

Tried it. Doesn't work. Am I really missing something? I'm running Windows 7 Professional with Access 2007
It worked for me with Access XP (2002) connecting to an .mdb on Windows 7 Professional. Since it is deprecated maybe it doesn't support the new .accdb format.
It also worked for me with Access 2007 connecting to an .accdb on Windows XP Professional. I don't have a Win7 machine with Access 2007 installed, so I can't replicate your environment.
ok, I am really mystified now... Everything I try always gives me the same error string.
@SwimmingCode Do you have some solution to this question you posted without resorting on using 32-bit python and pyodbc? I am running exactly into the same problem.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.