LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   PostgreSQL 8 and DBI, DBD::Pg (https://www.linuxquestions.org/questions/linux-software-2/postgresql-8-and-dbi-dbd-pg-282318/)

rnturn 01-25-2005 11:03 PM

PostgreSQL 8 and DBI, DBD::Pg
 
Say, has anyone used the above combination... successfully?

I recently compiled PostgreSQL 8 on a SuSE 9.2 system and haven't been having much luck getting a formerly working Perl script to be able to connect to the database since the database upgrade.

Software versions: SuSE 9.2, Pg 8.0.0 (compiled from sources w/ ./configure --with-perl), DBI-1.43-2 (from the 9.2 CDs), and DBD::Pg-1.22-198 (downloaded from Novell/SuSE site).

The line that's failing is:
Code:

$dbh = DBI->connect("dbi:Pg:dbname=$db", "", "", "") || die $DBI::errstr;
where $db has been set to "test". The error message it's kicking out is:
Code:

Can't use string ("") as a HASH ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.5/i586-linux-thread-multi/DBI.pm line 515.
As I recall from when I wrote the script (a year or so ago), the first two null strings in the statement were interpretted as allowing access to the current user.

If I change that line to use a couple of variables containing username and password info:
Code:

$dbh = DBI->connect("dbi:Pg:dbname=$db", $username, $password, {RaiseError => 1}) || die $DBI::errstr;
the program just hangs at the "connect" statement. If I leave out the "RaiseError blah" I get the above error message again. (This used to be allowed and you could use a statement "$dbh->{RaiseError}=> = 1;" following the $dbh->connect(). Apparently that doesn't work any more. :-( )

This seems awfully weird to me that this interface would now be this broken; especially when when of the main PostgreSQL developers is an admin on the DBD::Pg project.

So... Anyone got any experience along these lines? Pg 8 is pretty new so I guess it's possible that the perl interface hasn't caught up yet so I'm monitoring traffic on as many Pg sites as I can find in case something turns up.)

Could this be a SuSE 9.2 problem?

TIA

--

PS. If the above is littered with weird "+ACQ-" and similar strings and the like, will someone please explain how the heck you're supposed to be able to post code with some silly parser mucking it up all the time?

krishnajai 02-22-2005 02:30 AM

You might want to try DBIx::Password to hold all the handle information before you make the DBI connection. Make sure it comes before the code that tries to use it!


All times are GMT -5. The time now is 09:12 PM.