in reply to Cross-platform DB

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.

Replies are listed 'Best First'.
Re^2: Cross-platform DB
by wpahiker (Acolyte) on Feb 21, 2007 at 16:30 UTC
    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
        Still getting the same error, thinking something wasn't installed where it should be:
        J:\BSACamps.tst\CGI>perl test.cgi Can't locate DBI.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/l +ib .) at test.cgi line 6. BEGIN failed--compilation aborted at test.cgi line 6.
        Line 6 is the "use dbi;"
      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 :)

        Ahhh ... now I get it. Yes, aren't you using ActivePerl? If so, use ppm to install whatever module you need/want. If not, what version of perl are you using? Strawberry? Indigo? Cygwin?

        -derby
      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?
Re^2: Cross-platform DB
by admiral_grinder (Pilgrim) on Feb 23, 2007 at 16:26 UTC
    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.