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

I'm trying to create an application which needs to run on Mac/Unix/Windows platforms. The application isn't difficult, and a simple DBM would suffice, except that the Windows platforms are constrained to the 1k limit. What I'm looking for is a DBM that can be used on all three platforms, and is easy (read simple) to install. Went to the Oracle/Berkeley DB site and downloaded their 4.5 implementation, couldn't make any sense out of how to install it from what they had, so I gave up on it (did I say, easy to install?). Any suggestions? Thanks, Mike

Replies are listed 'Best First'.
Re: Cross-platform DB
by monkey_boy (Priest) on Feb 21, 2007 at 14:20 UTC
    sqlite is nice and simple, works well on most OS.


    This is not a Signature...
Re: Cross-platform DB
by dragonchild (Archbishop) on Feb 21, 2007 at 14:09 UTC
    You're looking for DBM::Deep. It automatically marshals Perl datastructures and can act as a DBM without a problem. 1.0000 will also have transactions. :-)

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: Cross-platform DB
by philcrow (Priest) on Feb 21, 2007 at 14:20 UTC
    You might also like http://www.sqlite.org. Their unix version works fine on Mac and there is a windows version. It's light and fast and the easiest install I have ever done (I did it manually on Linux).

    Phil

Re: Cross-platform DB
by derby (Abbot) on Feb 21, 2007 at 14:29 UTC

    DBD::SQLite would be a good start -- as easy to install as dbm and the power of an RDBMS.

    -derby

    update: Wow! two other sqlite suggestions. The great thing about DBD::SQLite is that it has sqlite as part of it's distribution - no need to install sqlite first and then install the perl mod.

      OK, being new to this, I am really beginning to feel dense. I downloaded SQLite, but don't know what to do with it. What do you do with a .kit file????

      I also tried DBMDeep, but couldn't get it to work from the docs. I ran the "makefile.pl", and received the following:

      J:\BSACamps.tst\CGI\DBM-Deep-0.99_04>perl makefile.pl Checking if your kit is complete... Looks good Warning: prerequisite Clone 0.01 not found. Warning: prerequisite FileHandle::Fmode 0.05 not found. Warning: prerequisite Test::Deep 0.095 not found. Warning: prerequisite Test::Exception 0.21 not found. Writing Makefile for DBM::Deep
      I created their test program:
      #!/usr/bin/perl use DBM::Deep; my $db = new DBM::Deep "foo.db"; $db->{mykey} = "myvalue";
      but received the following when I went to run it:
      Can't locate DBM/Deep.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/s +ite/lib .) at test.cgi line 2. BEGIN failed--compilation aborted at test.cgi line 2.

        for sqlite, (shamelessly lifted from the cookbook):

        #!/usr/bin/perl use strict; use warnings; use DBI; # what's your data look like? my %monks = ( '8930' => 'derby', '581658' => 'wpahiker', '961' => 'Anonymous Coward', '104919' => 'perrin' ); # create the database handle my $dbh = DBI->connect( "dbi:SQLite:monastery.dat" ); # create a table $dbh->do( "CREATE TABLE monks (id INTEGER PRIMARY KEY, name)" ); # insert values foreach my $monkid ( keys %monks ) { $dbh->do( "INSERT INTO monks VALUES ($monkid, '$monks{$monkid}')" ); } # fetch data my $sql = "select * from monks"; my $res = $dbh->selectall_arrayref( $sql ); foreach my $rec (@$res) { print "$rec->[1] is $rec->[0]\n"; } $dbh->disconnect;

        -derby
        Are you using ActivePerl? If so, why not just install DBM::Deep from the PPM? (As DBM-Deep) Recent ActivePerl releases include PPM v4, which is GUI based :)
        I think you may have skipped a step or two on the module install... Usually it's:

        perl makefile.pl make make install

        See if that helps?
      I agree with this. SQLite is very easy to use. Each database is stored in its own easy to find (and backup) file. Helps too when there is a useful tool like the SQLite Database Browser (sourceforge.net). Note on using this tool though is that when you modify the database, you have to save it to remove the lock it puts in place.
Re: Cross-platform DB
by marto (Cardinal) on Feb 21, 2007 at 14:16 UTC
    Regards installing Oracle/Berkeley BD, I did this only yesterday on Solaris. I unpacked the tar file and did the following:
    cd build_unix sh -c "CC=gcc ../dist/configure --prefix=/you/install/path/here" make make install

    Oracle have documentation for building on Win32 and OS X platforms also. dragonchild has advised you of an alternative if you do not have your heart set on Berkeley DB.

    Hope this helps.

    Martin
Re: Cross-platform DB
by perrin (Chancellor) on Feb 21, 2007 at 15:28 UTC
    There's probably a PPM for BerkeleyDB or DB_File on Windows.