Anything available that can read Microsoft .MDB files from Python?

kyosohma at gmail.com kyosohma at gmail.com
Mon Mar 19 16:01:57 EDT 2007


On Mar 19, 2:45 pm, John Nagle <n... at animats.com> wrote:
> Diez B. Roggisch wrote:
> > John Nagle schrieb:
>
> >>   I'm looking for something that can read .MDB files, the format
> >> Microsoft Access uses, from Python.  I need to do this on
> >> Linux, without using Microsoft tools.  I just need to read
> >> the files once, so I can load the tables into another database.
> >> Speed isn't an issue, and I don't need to access the file in
> >> database fashion.  The files are too big to read into RAM all at once,
> >> though.
>
> >>   I tried "MDBtools", but the only (last) release was
> >> a pre-release three years ago, and I've encountered
> >> many build problems trying to make it work on Fedora
> >> Core 6.
>
> > I was just gonna suggest it. Under ubuntu, it works easy as cake, and
> > converts the mdb nicely to some CSV-files.
>
> > I think you should really try and make it work.
>
> > Diez
>
>     What MDBtools did you install?  The RPM, a checkout from CVS,
> or the downloadable distribution?  They're all different.
>
>                                 John Nagle

I've read .MDB files using ODBC. I don't know how big your files are,
but I had a file with almost 3000 rows and I was able to fetch it in
1-2 seconds. If you want to give it whirl, you just need to create an
ODBC connection and then do the following:

myconn = odbc.odbc('mydb_connection_name')
mycursor = myconn.cursor()
mycursor.execute('SELECT * FROM db_name')
mydata = mycursor.fetchall()
mycursor.close()
myconn.close()

for each in mydata:
   # do something like pull the info from the variable "mydata" and
send it into the other database


It is fast. But you may like what the others have said more.

Mike




More information about the Python-list mailing list