Thread: Help needed with pg.pm to connect to postgresql
hi, Im using linux and i have postgresql 6.5 and perl 5.003 installed on system. Im having problems connecting to postgresql where as ive pgsql_perl5 installed, only that im not sure whether its configured propely. well this is the error i incur whenever i try to run my program :- "can't locate pg.pm in @INC(@INC contains :/usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005.) at connect.cgi BEGIN failed --compilation aborted at connect.cgi " well this my short perl program: #!/usr/local/bin/perl # #perl sample program use pg; $conn =pg::connectdb("dbname=test"); die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status; print "Enter User name :" $username = <STDIN>; chomp $username; $result = $conn->exec( "SELECT firstname,lastname,state,city,age from friends WHERE firstname = 'username'"); die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultstatus; while (@row = $result->fetchrow) { print @row, "\n"; } please help. thanks bye Bonface Kisala. ----------------------------------------------- FREE! The World's Best Email Address @email.com Reserve your name now at http://www.email.com
You have 2 small mistake that I point below. On Sat, 4 Nov 2000, Kisala Muhavi wrote: > #!/usr/local/bin/perl > # > #perl sample program > > use pg; use Pg; > > $conn =pg::connectdb("dbname=test"); > die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status; > > print "Enter User name :" print "Enter User name:"; The rest compiles OK -- Jesus Aneiros Sosa mailto:aneiros@jagua.cfg.sld.cu http://jagua.cfg.sld.cu/~aneiros
Saluton, On Sat, Nov 04, 2000 at 09:40:51AM -0500, Kisala Muhavi wrote: ... > installed, only that im not sure whether its configured propely. well this > is the error i incur whenever i try to run my program :- > > "can't locate pg.pm in @INC(@INC contains :/usr/lib/perl5/5.00503/i386-linux > /usr/lib/perl5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux > /usr/lib/perl5/site_perl/5.005.) at connect.cgi > BEGIN failed --compilation aborted at connect.cgi " ... The error message tells you that perl does not find the pg.pm file. Maybe you should try Pg (with capital P) instead of pg; or, if that does not help, use find to look where the file resides and put it into one of the directories mentioned in the error message, or augment @INC to contain the relevant directory. HTH, Albert. -- -------------------------------------------------------------------------- Albert Reiner <areiner@tph.tuwien.ac.at> Deutsch * English * Esperanto * Latine --------------------------------------------------------------------------