in reply to Re^2: Cross-platform DB
in thread Cross-platform DB

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

Replies are listed 'Best First'.
Re^4: Cross-platform DB
by Anonymous Monk on Feb 21, 2007 at 18:12 UTC
    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;"

      You need to install DBI and DBD::SQLite. As others have asked, what perl are you using? If Activestate, then by using ppm, these dependencies are auto-magically resolved for you.

      -derby
        On the current (windows) system I am at:
        This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 25 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 817 [257965] provided by ActiveState http://www.ActiveSta +te.com Built Mar 20 2006 17:54:25
        So, I guess I'm using activestate. As I said earlier, I'm new to all of this (windows systems). I did a search and found DBI.pm at C:\Perl\site\lib\PerlEx, so I'm not sure why it's not finding it.

        As to installing DBD::SQLite, again, I went to the site, the download was a .kit file, what do I do with a .kit file????

        I know this will turn most stomachs, but I'm a Mac person. If this didn't have to be cross-platform there would be no problem. MS doesn't like DBM records over 1k, not a problem with the Mac. I'm trying to find a working solution for both platforms.