M
marko
This is my script in its current (troubleshooting) state:
----------------------------------------------------------
#!/usr/bin/perl -w
use DBI;
#use DBD:g;
use strict;
my $dbname = "test";
my $dbh = DBI->connect("DBIg:dbname=
$dbname;host=localhost;port=5432","","",
{RaiseError => 1, PrintError => 1 })
or die "Can't connect to the db: $DBI::errstr\n";
if (undef $dbh) {die "cannot connect to database:$!\n";}
else {print "Success connecting!\n";}
my $statement = "select count(*) from tex_births";
my $rc = $dbh->ping; # this is the line returning the 'can't call
method 'ping' error'
print $rc . "\n";
#my $sth = $dbh->prepare($statement)
# or die "Can't prepare SQL statement: $DBI::errstr\n";
#if ( undef $sth ) {die "Could not prepare statement:$!\n";}
#$sth->execute or die "Can't Execute statement: $DBI::errstr\n";
while (my @row_ary = $dbh->selectrow_array($statement)) {
#while ( my @row = $sth->fetchrow_array() ) {
print @row_ary,"\n"; }
#$sth->finish;
$dbh->disconnect;
-------------------------------------------------------------------------
Perl, this script and postgresql are all running on this same
machine. The connect() method is what I would suspect as being the
culprit, naturally, but the die is not being triggerred and a
$DBI::errstr is not being printed out. In fact, a 'Success
connecting!' is instead being printed and the next output line is
'can't call method 'ping' on an undefined value'.
The log file to postgresql doesn't show anything out of the ordinary
at all! The psql command line is working fine connected to the
postgresql server, so I don't think its a server issue. **I'm really
stumped on this one.** Would anyone like to take a stab at helping me
find my way? Please?
----------------------------------------------------------
#!/usr/bin/perl -w
use DBI;
#use DBD:g;
use strict;
my $dbname = "test";
my $dbh = DBI->connect("DBIg:dbname=
$dbname;host=localhost;port=5432","","",
{RaiseError => 1, PrintError => 1 })
or die "Can't connect to the db: $DBI::errstr\n";
if (undef $dbh) {die "cannot connect to database:$!\n";}
else {print "Success connecting!\n";}
my $statement = "select count(*) from tex_births";
my $rc = $dbh->ping; # this is the line returning the 'can't call
method 'ping' error'
print $rc . "\n";
#my $sth = $dbh->prepare($statement)
# or die "Can't prepare SQL statement: $DBI::errstr\n";
#if ( undef $sth ) {die "Could not prepare statement:$!\n";}
#$sth->execute or die "Can't Execute statement: $DBI::errstr\n";
while (my @row_ary = $dbh->selectrow_array($statement)) {
#while ( my @row = $sth->fetchrow_array() ) {
print @row_ary,"\n"; }
#$sth->finish;
$dbh->disconnect;
-------------------------------------------------------------------------
Perl, this script and postgresql are all running on this same
machine. The connect() method is what I would suspect as being the
culprit, naturally, but the die is not being triggerred and a
$DBI::errstr is not being printed out. In fact, a 'Success
connecting!' is instead being printed and the next output line is
'can't call method 'ping' on an undefined value'.
The log file to postgresql doesn't show anything out of the ordinary
at all! The psql command line is working fine connected to the
postgresql server, so I don't think its a server issue. **I'm really
stumped on this one.** Would anyone like to take a stab at helping me
find my way? Please?