• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5401: Support for SQLite

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension DatabasePlugin Enhancement New   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

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

ItemTemplate
Summary Support for SQLite
ReportedBy TWiki:Main.LarsEik
Codebase 4.2.0
SVN Range TWiki-5.0.0, Wed, 23 Jan 2008, build 16283
AppliesTo Extension
Component DatabasePlugin
Priority Enhancement
CurrentState New
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Topic revision: r1 - 2008-02-29 - LarsEik
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback