I am still having problems with a script trying to use SQLite2. My 4
line test script works fine, but my other code keeps giving me DBI
errors saying it can't find the table. Here is what I get in the DBI
trace.
!! ERROR: 1 'no such table: trapdlog(1) at dbdimp.c line 412'
(err#0)
<- execute('1094662322' '3' ...)= undef at logwiz.pl line 377
DBD::SQLite2::st execute failed: no such table: trapdlog(1) at dbdimp.c
line 412 at ./logwiz.pl line 377.
no such table: trapdlog(1) at dbdimp.c line 412 at ./logwiz.pl line 377.
<- disconnect_all= '' at DBI.pm line 674
ERROR: 1 'no such table: trapdlog(1) at dbdimp.c line 412'
(err#0)
! <- DESTROY(DBI::st=HASH(79dd10))= undef during global destruction
The code I'm using:
my $lite_dbh = &sqlite_connect();
# prepare the update statement
my $lite_sth_update = $lite_dbh->prepare( q{ UPDATE trapdlog SET status
= ? WHERE node = ? } )
or syslog_die($DBI::errstr);
# prepare the insert statement
my $lite_sth_insert = $lite_dbh->prepare( q{ INSERT INTO trapdlog
(epochtime, trap_category,
trap_create_time,
ip_hostname, trap_source,
description, status)
VALUES (?,?,?,?,?,?,?) } )
or syslog_die($DBI::errstr);
# prepare the select statement
my $lite_sth_select = $lite_dbh->prepare( q{ SELECT status FROM trapdlog
WHERE node = ? } )
or syslog_die($DBI::errstr);
$lite_sth_select->execute($node) or die $DBI::errstr;
my $status = $lite_sth_select->fetchrow;
$lite_sth_update->execute("$node","CLEAR") or die
$DBI::errstr;
$lite_sth_insert->execute("$epochtime","$trap_category",
"$t_date",
"$node", "$trap_source",
"$ndescription",
"DOWN") or die $DBI::errstr;
sub sqlite_connect {
# need to add code in here to check that the database exists. if it
does not we
# will create it. *thought*.
my $sqlite_dbh =
DBI->connect("dbi:SQLite2:dbname=trapdlog.db","","")
or die $DBI::errstr;
return $sqlite_dbh;
}
*** Note new e-mail address
--
Michael J. Freeman
Netco Government Services
[EMAIL PROTECTED]
--