Item5401: Support for SQLite
Priority: Enhancement
Current State: No Action Required
Released In:
Target Release: n/a
I finally managed to hack access to a local sqlite database file. But it seems that the perl syntax is different when connecting to sqlite, it uses
"DBI:$this->{driver}:dbname=$this->{database}..etc
where other databases uses
database
instead of
dbname
A developer could fix this if it isn't already fixed in svn.
The file is "lib/TWiki/Plugins/DatabasePlugin/Connection.pm" and the
sub connect
I used this code, not galant but it works with two simultanous db's, mysql and sqlite:
sub connect {
my $this = shift;
unless ($this->{db}) {
my $sid = $this->{sid} ? ";sid=$this->{sid}" : '';
my $dbn;
if (lc( $this->{driver}) eq 'sqlite' ) {
$dbn = "dbname";
} else {
$dbn = "database";
}
my $db = DBI->connect(
# NEXT LINE WAS ORIGINAL, SECOND LINE USES $dbn FROM IF ABOVE INSTEAD
#"DBI:$this->{driver}:database=$this->{database};host=$this->{hostname}$sid",
"DBI:$this->{driver}:$dbn=$this->{database};host=$this->{hostname}$sid",
$this->{username}, $this->{password},
{PrintError=>1, RaiseError=>1});
if (! $db ) {
die "Can't open database specified by description '$description'";
}
$this->{db} = $db;
}
}
--
TWiki:Main/LarsEik - 29 Feb 2008
I got SQLite working without modification on trunk so this was either my RTFM or is solved otherwise.
--
Foswiki:Main.LarsEik - 02 Dec 2008