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

Ok, first off... using MS-Access is not my choice... my company is too cheap to buy anything and its access 97, so it's pitiful even by MS standards. but here's the deal. I'm importing and exporting data into a "pool" for something resembling historical data mining. But alas, as Access sucks... it has that stupid 1GB limit and with MS's wonderful memory optimization needs to be compacted often. I'm currently using the DBI module to do my DB work... I was wondering if there was a module/method that would allow me to compact this database from the script
  • Comment on Compacting a MS-Access database from perl

Replies are listed 'Best First'.
Re: Compacting a MS-Access database from perl
by jsprat (Curate) on Jun 05, 2003 at 19:54 UTC
    I'm stuck with Access 97 too.

    You can use OLE to compact a database. Here's a fish:

    use Win32::OLE; # check your registry for which version DBEngine to use my $dao = Win32::OLE->new('DAO.DBEngine.36', 'quit') or die "$!"; $dao->CompactDatabase('c:\\test.mdb', 'c:\\test2.mdb');

    Check the Access helpfile for available options

    HTH!

      That took care of it. Thank all you monks a ton for your input. I still had trouble finding decent doc on how OLE works and what methods/objects are available. Problem solved... Perl > all yet again :)
Re: Compacting a MS-Access database from perl
by krisahoch (Deacon) on Jun 05, 2003 at 17:24 UTC
    Grygonos,

    This information I am about to give to you is probably not what you're looking for, but...

    <PaidForAdvertisement>

    Would you like to try a better, cheaper, more robust database engine? If so please click on any link that I have provided!!! It slices, It dices, and it drives the poorer preforming, yet more expensive competition into the Ground!!! And the best news yet, it official supports its own Perl api!!!

    </PaidForAdvertisement>

    Seriously though. MySql is supported for Windows 2000, it is opensource with GPLicense, and seems to be PerlHacker Database of Choice.

    PS. It is a real database engine, not a wanna be ...what ever the hell Access wants to be...


    Kristofer Hoch

    Si vos can lego is, vos es super erudio

      Access wants to be a frontend. And it works pretty good as a frontend. The major problem with Access is the database used as its backend (namely, Jet). Even Microsoft wants to ditch Jet (but that'll take a while, due to legacy apps). It is possible to use Access to a frontend to other databases, including MySQL, via ODBC.

      While better than Jet (which isn't saying much), MySQL has other problems. It implements the bare-minimum requirements to be relational, and transactions are only kinda, sorta working. At least it can keep track of its own mind, which is something Jet doesn't do.

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      Note: All code is untested, unless otherwise stated

        MySQL is my db of choice.. but this is corporate America and its not gonna happen... to make things worse... I don't technically work in the IT dept. here.. I'm fresh out of college witha BS in Computer Science and took the first job I got offered basically.. I do some gimpy work in which I find ways to incorporate perl, ruby , and java hehe... i found ole objects but can't find any good doc on them...
Re: Compacting a MS-Access database from perl
by Itatsumaki (Friar) on Jun 05, 2003 at 15:04 UTC

    I believe, if you move up to Access 2k or so you get a 2GB limit, but my experience is that above about 1GB you get lots of corruption issues.

    Anyhow, you can compact an MS-Access DB via the Win32 modules and I'm sure somebody here can give you the syntax for that particular command. I just want to caution you against it. My experience is that the compact/repair experience in Access causes tons of problems and generally should be done under full supervision. I can't count the number of times doing one/both has corrupted my DB or reverted back to older table structures and relationships. So, I'm not a big fan of automating it, and I would urge you to do some sort of testing afterwards, and to take a file-level backup (just copy the .mdb file) before.

    Hope this helps!
    -Tats
Re: Compacting a MS-Access database from perl
by dws (Chancellor) on Jun 05, 2003 at 16:30 UTC
    I was wondering if there was a module/method that would allow me to compact this database from the script.

    It can be done. I did it several years ago, but no longer have access to that script. However, I do recall digging the necessary information out of MSDN. This MSDN article might help. Alternatively, go do http://msdn.microsoft.com/ and search for "compact access database". You'll get a bunch of hits, some of which might contain what you're looking for.