I can vouch for DBD::SQLite. It rocks. :) The first hurdle with SQLite is the fact
that you have to have an egg before you can have chickens. What i mean is that you first
have to write a script that creates (and then optionally populates) the database file.
Something as trivial as:
use DBI;
use Data::Dumper;
my $dbh = DBI->connect(
'dbi:SQLite:dbname=dbfile','','',
# { RaiseError => 1},
);
eval {
$dbh->do('drop table foo');
$dbh->do('create table foo(id int unsigned, name char(64))');
};
my $sth = $dbh->prepare('insert into foo values (?,?)');
$sth->execute(@$_) for [1,'moe'],[2,'curly'],[3,'larry'];
print Dumper $dbh->selectall_arrayref('select * from foo');
However, you may notice from the code that i am supplying the ID. I do not think that SQLite
offers auto-incremented ID's for you.
Alternatively, if you already have your data stored in another format, check out
SQL Fairy before you roll your own.
UPDATE:
That's right ... thanks for pointing out my error (once again!) merlyn. :)
Here is are updated lines for the snippet above:
$dbh->do('create table foo(id integer primary key, name char(64))');
my $sth = $dbh->prepare('insert into foo(name) values (?)');
$sth->execute($_) for qw(moe curry lary);
Much better. ;)
|