0

How do I query an Access *.mdb database from Python 2.7?

Additional info: I'm on a 64-bit Windows 7 OS (It's important because all the other answers I found on Stack Overflow are for 32-bit.)

Edit: I have 32-bit Office 2010 installed.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
user3585792
  • 103
  • 3
  • Please [edit] your question to indicate whether you have MS Office installed on the machine. If you do have Office installed, be sure to mention **(1)** which version of Office (... 2007? ... 2010?) and **(2)** whether it is the 32-bit or the 64-bit build. – Gord Thompson Nov 20 '14 at 09:56
  • https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#safe=off&q=python%202.7%20odbc – ta.speot.is Nov 20 '14 at 10:02

1 Answers1

0

You have 32-bit Office installed on your machine so you need to use a 32-bit version of Python to manipulate your database file(s). You should be able to confirm the bit-ness of your Python by simply starting it up, e.g.,

C:\Users\Gord>python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

You also need an ODBC component for Python. I recommend pypyodbc. The main pypyodbc page has sample code, and there is also a tutorial here.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418