ralphie has asked for the wisdom of the Perl Monks concerning the following question:
i have what seems to me to be an interesting problem ... i'm converting a series of html docs and cgi scripts that i use as a query engine to a couple of cgi scripts, one which receives authentication information while the other handles query processing. the query page is frame-based, and follows the example included in the cgi.pm readme.
the problem i'm having is that the connect string in the converted script won't work using variables for username and password. here's the output from the dbitrace log from the connect attempt...
DBI 1.20-nothread dispatch trace level set to 2 -> DBI->connect(DBI:Pg:dbname=jrado;host=raider-ralph, , ****) -> DBI->install_driver(Pg) for linux perl=5.006001 pid=3030 ruid=1 +001 euid=1001 install_driver: DBD::Pg version 1.01 loaded from /usr/local/lib +/perl/5.6.1/DBD/Pg.pm <- install_driver= DBI::dr=HASH(0x82459e4) -> default_user in DBD::_::dr for DBD::Pg::dr (DBI::dr=HASH(0x8245 +9e4)~0x82ec3d8 undef undef HASH(0x8109d38)) <- default_user= ( undef undef ) [2 items] at DBI.pm line 423 -> connect for DBD::Pg::dr (DBI::dr=HASH(0x82459e4)~0x82ec3d8 'dbn +ame=jrado;host=raider-ralph' undef **** HASH(0x8109d38)) pg_db_login pg_db_login: conn_str = >dbname=jrado host=raider-ralph<br> No Postgres username specified in startup packet. error 1 recorded: No + Postgres username specified in startup packet. !! ERROR: 1 'No Postgres username specified in startup packet.'
the log from a successful connection attempt, which i get when i explicitly pass a valid set of credentials in the connect string, is identical to that which i receive in the relevant portion of the earlier version when i pass the credentials in scalars. that log looks like this:
DBI 1.20-nothread dispatch trace level set to 2 -> DBI->connect(DBI:Pg:dbname=jrado;host=raider-ralph, (username d +eleted for post), ****) -> DBI->install_driver(Pg) for linux perl=5.006001 pid=32422 ruid= +1001 euid=1001 install_driver: DBD::Pg version 1.01 loaded fro +m /usr/local/lib/perl/5.6.1/DBD/Pg.pm <- install_driver= DBI::dr=HASH(0x8225fd8) -> connect for DBD::Pg::dr (DBI::dr=HASH(0x8225fd8)~0x8100750 'dbn +ame=jrado;host=raider-ralph' '(username deleted for post)' **** HASH( +0x80f6174)) pg_db_login pg_db_login: conn_str = >dbname=jrado host=raider-ralph user=(username + deleted) password=(password deleted) <- connect= DBI::db=HASH(0x8100714) at DBI.pm line 426
in both scripts the $username and $password scalars are successfully filled from parameters, and the connect statement is the standard $dbh=DBI->connect($dsn,$username,$password) or die print "error connecting to database ", $DBI::errstr, "\n";
obviously, the scalar values are not getting passed in the connect string in the problematic context, but at this point i'll be darned if i can figure out why. (those who feel i'm being excessively politically-correct by not using the more appropriate word above should recognize that i'm at a state computer, and lawyerz are everywhere.)
has anyone run into this before? i don't have enough hair left to keep pulling it out like this ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: postgresql dbi connection problem
by krazken (Scribe) on Dec 18, 2001 at 22:50 UTC | |
|
Re: postgresql dbi connection problem
by Zapawork (Scribe) on Dec 19, 2001 at 13:38 UTC | |
|
Re: postgresql dbi connection problem
by ralphie (Friar) on Dec 20, 2001 at 01:35 UTC |