#!/usr/bin/perl -w
package TEST;
BEGIN {
$|=1;
use CGI::Carp('fatalsToBrowser');
}
### Load Required Modules ###
use strict;
use DBI;
use CGI qw/:standard/;
### Variable init. ###
$TEST::CGI = new CGI;
print $TEST::CGI->header;
my $db = "/hsphere/local/home/katom/bnei-yehuda.co.il/texts/SheepWool/test.db";
my $log = "/hsphere/local/home/katom/bnei-yehuda.co.il/texts/SheepWool/test.log";
unlink $log if -e $log;
my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","", { RaiseError => 1 })
or die $DBI::errstr;
DBI->trace(6, $log);
print "Preparing and executing CREATE TABLE statement.
";
my $sth = $dbh->prepare("
CREATE TABLE users (
id INTEGER NOT NULL,
name VARCHAR(128)
)
"
);
$sth->execute;
print "Preparing and executing INSERT statement.
";
my $username = $dbh->quote("ido50");
$sth = $dbh->prepare("
INSERT INTO users VALUES (1, $username)
");
$sth->execute;
print "Preparing and executing a SELECT statement.
";
$sth = $dbh->prepare("
SELECT * FROM users
WHERE id = 1
");
$sth->execute;
my @row = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;
exit;