I am new to Databse. I installed SQLite on my system and tried running PERL program to insert into databse
SQLite commands to create database and table
In command prompt, I iterated to SQlite directory and given commands as
sqlite3 one.db;
create table table1 (a int, b string);
It created a database and table
I executed the followed PERL program
use strict;
use warnings;
use DBI;
use DBD::SQLite;
my $dbh = DBI->connect("dbi:SQLite:dbname=one.db","","") or die "cannot
connect";
my $sth = $dbh->prepare("INSERT INTO 'table1'
(Income, LAST_NAME )
values
('1000', 'poul')");
$sth->execute() or die $DBI::errstr;
$sth->finish();
$dbh->commit or die $DBI::errstr;
I got the following error
DBD::SQLite::st execute failed: no such table: table1 at DBI.txt line 14.
no such table: table1 at DBI.txt line 14.
After getting comments from IKEGAMI, I changed the DBI->connect as
my $dbh = DBI->connect
("dbi:SQLite:dbname=C:/Users/nitkumar/Downloads/sqllite/one.db","","
") or die "cannot connect";
I started getting error message as
DBI connect('dbname=C:/Users/nitkumar/Downloads/sqllite/one.db','',...) failed:
database disk image is malformed at DBI.txt line 8
cannot connect at DBI.txt line 8.
After getting more comments i got the version by using
use DBD::SQLite;
warn $DBD::SQLite::VERSION;
warn $DBD::SQLite::sqlite_version;
I got the output as
1.37 at version.txt line 2.
3.7.12.1 at version.txt line 3.
I am using sqlite3 . I guess there are no issues with version
c://sqlitefolderb textmakes more sense thanb stringuse DBD::SQLiteline. The DBI modules loads the correct DBD automatically.