Does the $dsn contain the full path to the database?

--
Octavian

----- Original Message ----- From: "Dermot" <paik...@gmail.com>
To: "Perl Beginners" <beginners@perl.org>
Sent: Friday, July 16, 2010 7:29 PM
Subject: DBI under SOAP/mod_perl


Hello All,

(This is perl, v5.8.8). Sorry if this is a bit specialised (EG not v.
beginner) but I'm getting rather frustrated and could use some help.


I have a strange issue with a DBI/DBD::SQLite. I have a class that
creates an instance of DBI, EG:

package Foo;

use strict;
use warnings;
use DBI;
use Carp;

my $DEBUG = 1

sub new {
   my $class = shift;
   my %args = @_;
   my $self = {};
   $self->{debug} = $args{debug} || $DEBUG;
   .....
   .....
   $self->{dbh} = DBI->connect($dsn,'','', { PrintError=>1,
PrintWarn=>1} ) or confess "Can't connect: DBI->errstr: $!\n";

   bless $self, $class;
   return $self;
}

sub dbh {
   return $_[0]->{dbh};
}

sub get_record {
   my $self = shift;

   my $sql = q(SELECT * FROM records WHERE path = ?);
   my $sth = $self->dbh->prepare($sql);
   print STDERR "STH=$sth  DBH=".$self->dbh."\n";
   $sth->execute($self->file) or confess "Can't prepare: ".
$self->dbh->errstr."\n";
   while (my $href = $sth->fetchrow_hashref ) {
       print STDERR "Record found $href->{id} Rows=". $sth->rows."\n"
if $self->{debug};
       $self->{record} = $href;
   }
}

...

1;
###

When I create an instance from a command-line script all works fine.

my $foo = Foo->new();
$foo->get_record();

This prints: "STH=DBI::st=HASH(0x92b3f2c)  DBH=DBI::db=HASH(0x92b1ee4)"


The problem arise when I create an instance under a SOAP::Lite
package. The package is running under mod_perl's Registry. In the
HTTPD logs I see:

DBD::SQLite::db prepare failed: not an error at /etc/perl/Foo.pm line 190.
Use of uninitialized value in concatenation (.) or string at
/etc/perl/Foo.pm line 191 (#2)
STH=  DBH=DBI::db=HASH(0x8a1568c)


I suspect this is an oddity with mod_perl and SOAP but I can't see a
why through. Does anyone have any ideas what I might try? I can't
change the architecture and have to make this work within what's
installed.


Any ideas appreciated.
Thanx,
Dp,

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



__________ Information from ESET NOD32 Antivirus, version of virus signature database 5290 (20100718) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com





__________ Information from ESET NOD32 Antivirus, version of virus signature 
database 5290 (20100718) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to