LJ Archive

Listing 4. Perl Example

use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=dbfile",
                        "","");

my $cursor;
my @rec;

my $SQL = "select * from person order by lastname";

$cursor = $dbh->prepare($SQL);
$cursor->execute();

while(@rec = $cursor->fetchrow_array)
{
    print "$rec[0], $rec[1]\n";
}

$cursor->finish;
$dbh->disconnect;
LJ Archive