views:

1787

answers:

5

How can I access Microsoft Access databases in Python? With SQL?

I'd prefere a solution that works with Linux, but I could also settle for Windows.

I only require read access.

+4  A: 

How about pyodbc? This SO question demonstrates it's possible to read MS Access using it.

Stuart Dunkeld
+3  A: 

Most likely, you'll want to use a nice framework like SQLAlchemy to access your data, or at least, I would recommend it. Support for Access is "experimental", but I remember using it without too many problems. It itself uses pyodbc under the hood to connect to Access dbs, so it should work from windows, linux, os x and whatnot.

Nico
I need it only to import data to my SQLite backed Storm model. :)
Georg
A: 

If you sync your database to the web using EQL Data, then you can query the contents of your Access tables using JSON or YAML: http://eqldata.com/kb/1002.

That article is about PHP, but it would work just as well in Python.

apenwarr
+2  A: 

I've used PYODBC to connect succesfully to an MS Access db - on Windows though. Install was easy, usage is fairly simple, you just need to set the right connection string (the one for MS Access is given in the list) and of you go with the examples.

Alex Boschmans
+1  A: 

You've got what sounds like some good solutions. Another one that might be a bit closer to the "metal" than you'd like is MDB Tools.

MDB Tools is a set of open source libraries and utilities to facilitate exporting data from MS Access databases (mdb files) without using the Microsoft DLLs. Thus non Windows OSs can read the data. Or, to put it another way, they are reverse engineering the layout of the MDB file.

Also note that I doubt they've started working on ACCDB files and there is likely not going to be much request for that capability.

Tony Toews