Обсуждение: Quick perl question

Поиск
Список
Период
Сортировка

Quick perl question

От
bweaver@tranquility.net
Дата:
Hey all,

I probably totally missed the docs on it, but I put PostgreSQL on 
my FreeBSD 3.4 box and I wanted to use some CGI scripts written 
in perl.  I installed Postgre 6.5.3 using the commands 'make 
USE_PERL=yes' and then 'make install'.  The installation is fine, 
but when I tried to make perl scripts using the Pg.pm library, I keep 
getting a "Can't locate Pg.pm in @INC..."

I'm using perl5.  Did I do something in the installation incorrectly?

An example script would be: 

#!/usr/bin/perl5 -w

use Pg;

# then the rest of the script goes here.

Thanks in advance,

-Ben


Re: [INTERFACES] Quick perl question

От
Ed Loehr
Дата:
bweaver@tranquility.net wrote:
> 
> Hey all,
> 
> I probably totally missed the docs on it, but I put PostgreSQL on
> my FreeBSD 3.4 box and I wanted to use some CGI scripts written
> in perl.  I installed Postgre 6.5.3 using the commands 'make
> USE_PERL=yes' and then 'make install'.  The installation is fine,
> but when I tried to make perl scripts using the Pg.pm library, I keep
> getting a "Can't locate Pg.pm in @INC..."
> 
> I'm using perl5.  Did I do something in the installation incorrectly?

This probably doesn't answer your immediate question, but it might
render it irrelevant.  You may want to look into the perl DBI module
at CPAN along with DBD::Pg.  DBI is very clean and is the standard
means for accessing RDBMS (including postgres) from perl.

Cheers,
Ed Loehr


Re: Quick perl question

От
Mark Dalphin
Дата:
Hi Ben,

Just a guess, but I suspect your installation went "slightly wrong".  When you
"make install" PostgreSQL, you do it as User "postgres".  It turns out that User
postgres does not have the required "root" permission to install Perl
extensions.  If you read thru your "make install log" carefully, you'll probably
see an error message to that effect just after the attempted install of Pg.pm.

I also would like to echo the comments that someone else has made about using
DBI::DBD rather than Pg.  Pg works well and is slightly easier to get working,
but that is because the complexity of DBI::DBD adds some useful stuff not
present in Pg. In particular, the error trapping is great. On the down side, it
gets tedious writting each query as two parts: "prepare" and "execute".  This is
compensated for in overall portability to other DBMS, I think.

You also need root permission to install DBI::DBD.

> I probably totally missed the docs on it, but I put PostgreSQL on
> my FreeBSD 3.4 box and I wanted to use some CGI scripts written
> in perl.  I installed Postgre 6.5.3 using the commands 'make
> USE_PERL=yes' and then 'make install'.  The installation is fine,
> but when I tried to make perl scripts using the Pg.pm library, I keep
> getting a "Can't locate Pg.pm in @INC..."
>
> I'm using perl5.  Did I do something in the installation incorrectly?
>
Mark Dalphin



Re: [INTERFACES] Re: Quick perl question

От
Ed Loehr
Дата:
> I also would like to echo the comments that someone else has made about using
> DBI::DBD rather than Pg.  Pg works well and is slightly easier to get working,
> but that is because the complexity of DBI::DBD adds some useful stuff not
> present in Pg. In particular, the error trapping is great. On the down side, it
> gets tedious writting each query as two parts: "prepare" and "execute".  This is
> compensated for in overall portability to other DBMS, I think.

You may also avoid that downside by encapsulating prepare() and
execute(), eg. 
sub mySelect {    ...    prepare...    execute...    ...}

Regards,
Ed Loehr


unsubscribe katkin.1@osu.edu

От
Michael Katkin
Дата:
unsubscribe katkin.1@osu.edu