pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
DBI connect returning an empty hash
2+ messages / 1 participants
[nested] [flat]

* DBI connect returning an empty hash
@ 2006-04-06 16:34 Scott Cain <cain@cshl.edu>
  2006-04-06 18:04 ` Re: DBI connect returning an empty hash Scott Cain <cain@cshl.edu>
  0 siblings, 1 reply; 2+ messages in thread

From: Scott Cain @ 2006-04-06 16:34 UTC (permalink / raw)
  To: pgsql-interfaces

Hi all,

I am developing a perl module that, when it is created, establishes a
DBI connection to my postgresql database.  The problem I am having is
that when I issue a DBI->connect command, the database handle it returns
is empty (Data::Dumper shows it as an empty hash).  Here is my code:

sub new {
    my $class = shift;
    my %arg   = @_;

    my $self  = bless {}, ref($class) || $class;


    my $dbname = $arg{dbname};
    my $dbport = $arg{dbport};
    my $dbhost = $arg{dbhost};
    my $dbuser = $arg{dbuser};
    my $dbpass = $arg{dbpass};
    my $notrans= $arg{notransact};

    warn $dbname,$dbport,$dbhost;
    warn $dbuser,$notrans;

    my $dbh = DBI->connect(
        "dbi:Pg:dbname=$dbname;port=$dbport;host=$dbhost",
        $dbuser,
        $dbpass,
        {AutoCommit => $notrans,
         TraceLevel => 4}
    ) or die;

    warn Dumper($dbh);

    ...etc...

The trace output doesn't show anything strange, and DBI.pm at least
seems to think things went OK, because it doesn't `die` on that line.

I wrote a simple test script that does exactly the same thing, and it
works.  Does anyone have any suggestions for what might be going on
here?

Thanks,
Scott

-- 
------------------------------------------------------------------------
Scott Cain, Ph. D.                                         cain@cshl.edu
GMOD Coordinator (http://www.gmod.org/)                     216-392-3087
Cold Spring Harbor Laboratory




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: DBI connect returning an empty hash
  2006-04-06 16:34 DBI connect returning an empty hash Scott Cain <cain@cshl.edu>
@ 2006-04-06 18:04 ` Scott Cain <cain@cshl.edu>
  0 siblings, 0 replies; 2+ messages in thread

From: Scott Cain @ 2006-04-06 18:04 UTC (permalink / raw)
  To: pgsql-interfaces

Nevermind; sorry to have bothered this list about this.  It turns out
that when DBI/DBD::Pg is working correctly, the database handle does
look like a blessed empty hash, so that is not my problem.  There must
be something wrong with the way I am trying to cache the handle in my
module.

Thanks anyway,
Scott


On Thu, 2006-04-06 at 12:34 -0400, Scott Cain wrote:
> Hi all,
> 
> I am developing a perl module that, when it is created, establishes a
> DBI connection to my postgresql database.  The problem I am having is
> that when I issue a DBI->connect command, the database handle it returns
> is empty (Data::Dumper shows it as an empty hash).  Here is my code:
> 
> sub new {
>     my $class = shift;
>     my %arg   = @_;
> 
>     my $self  = bless {}, ref($class) || $class;
> 
> 
>     my $dbname = $arg{dbname};
>     my $dbport = $arg{dbport};
>     my $dbhost = $arg{dbhost};
>     my $dbuser = $arg{dbuser};
>     my $dbpass = $arg{dbpass};
>     my $notrans= $arg{notransact};
> 
>     warn $dbname,$dbport,$dbhost;
>     warn $dbuser,$notrans;
> 
>     my $dbh = DBI->connect(
>         "dbi:Pg:dbname=$dbname;port=$dbport;host=$dbhost",
>         $dbuser,
>         $dbpass,
>         {AutoCommit => $notrans,
>          TraceLevel => 4}
>     ) or die;
> 
>     warn Dumper($dbh);
> 
>     ...etc...
> 
> The trace output doesn't show anything strange, and DBI.pm at least
> seems to think things went OK, because it doesn't `die` on that line.
> 
> I wrote a simple test script that does exactly the same thing, and it
> works.  Does anyone have any suggestions for what might be going on
> here?
> 
> Thanks,
> Scott
> 
-- 
------------------------------------------------------------------------
Scott Cain, Ph. D.                                         cain@cshl.edu
GMOD Coordinator (http://www.gmod.org/)                     216-392-3087
Cold Spring Harbor Laboratory




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-04-06 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-06 16:34 DBI connect returning an empty hash Scott Cain <cain@cshl.edu>
2006-04-06 18:04 ` Scott Cain <cain@cshl.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox