# "connect" to sqlite database file, creating it if it doesnt exist
my $dbh = DBI->connect("dbi:SQLite:dbname=testing.sqlite","","");
# build/execute a CREATE statement from array of column names with all rows as type 'TEXT'
my $sql = sprintf 'CREATE TABLE rowdata ( %s )', join(' TEXT, ', @headers, ' TEXT');
$status = $dbh->do($sql);
# return error status if CREATE resulted in error
if (!defined $status) {
die "CREATE failed";
}
####
# build/execute an INSERT statement from array of field values
# note: all of these values are already DBI quoted
my $sql = sprintf 'INSERT INTO rowdata VALUES( %s )', join(',', @row);
$status = $dbh->do($sql);
# return error status if INSERT resulted in error
if (!defined $status) {
die "INSERT failed: ", $dbh->errstr;
}
####
INSERT failed:
near ")": syntax error(1) at dbdimp.c line 271