wyrickre has asked for the wisdom of the Perl Monks concerning the following question:

How would one go about extracting data from an .mdb file on a Unix platform? I've looked around CPAN and all I could find was Win32::ODBC which will only work on a Windows platform... We're getting the .mdb file via ftp and need to load its contents to a database.

Replies are listed 'Best First'.
Re: MS Access mdb files
by thunders (Priest) on Jun 19, 2002 at 21:03 UTC
    With an ODBC driver for *NIX, and DBI and DBD::ODBC something like this should work.
    #!/usr/bin/perl -w use DBI ; use strict; #connect to Access file via ODBC my $accessDSN = q(driver=Microsoft Access Driver (*.mdb);). q(dbq=/home/user/mydbfile.mdb); my $dbhA = DBI->connect("dbi:ODBC:$accessDSN",'','') or die "$DBI::errstr\n";
    keep in mind that Access SQL is somewhat crippled, and that many ODBC functions will not be availible because the DBI module, and the third party vendor will not support them. But you should be able to at least pull out data via select statements
    some odbc drivers

    This is a how to on this exact subject here

Re: MS Access mdb files
by vladb (Vicar) on Jun 19, 2002 at 18:56 UTC
    I had to deal with something similar. However, in my case I simply asked the vendor to export each table data in a separate CSV file. Parsing CSV is much more straightforward than raw mdb (especially with the help of tilly's Text::xSV module!) So, just a suggestion, you might appeal to them for a 'cleaner' data dump.

    Excuse me for not including any Perl code, however ;/.

    _____________________
    # Under Construction
      Try the following: On the UNIX/Linux machine install DBI and all the modules to support DBD::Proxy. On the Windows system install DBI, all the modules for DBD::Proxy, and DBD::ODBC. So you end up making a connection through a ProxyServer.
Re: MS Access mdb files
by Kanji (Parson) on Jun 19, 2002 at 21:00 UTC

    I've always gone the same route as vladb because CSV is infinitely more portable and workable, but if that isn't an option, you might want to look into something like MDB Tools.

        --k.