Thread: OT - pg perl DBI question

OT - pg perl DBI question

From
Glyn Astill
Date:
Hi chaps,

I'm trying yo run a perl script that uses DBI (Slonys
psql_replication_check.pl to be precise) and I'm getting the error:

Can't locate Pg.pm in @INC

Now I do have the file in /usr/lib/perl5/DBD/ but the script can't
see it. I'm guessing that unless I fudge it and put the absoloute
path in the script, I need to set some sort of path somewhere, but
I'm lost as to what or where.

Could someone point me in the correct direction please?






      ___________________________________________________________
Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/


Re: OT - pg perl DBI question

From
CaT
Date:
On Tue, Jan 29, 2008 at 04:24:05AM -0800, Glyn Astill wrote:
> I'm trying yo run a perl script that uses DBI (Slonys
> psql_replication_check.pl to be precise) and I'm getting the error:
>
> Can't locate Pg.pm in @INC
>
> Now I do have the file in /usr/lib/perl5/DBD/ but the script can't
> see it. I'm guessing that unless I fudge it and put the absoloute
> path in the script, I need to set some sort of path somewhere, but
> I'm lost as to what or where.
>
> Could someone point me in the correct direction please?

Run perl -V and see if the path is there for @INC. If it's there, check
such things as permissions. If not, ponder deeply as to why this is so
(as /usr/lib/perl5 is a standard path for perl in /usr) and if you can't
fix it 'properly' you can work-around with the use of 'use lib' (see
perldoc perlvar and search for @INC).

--
    "To the extent that we overreact, we proffer the terrorists the
    greatest tribute."
        - High Court Judge Michael Kirby

Re: OT - pg perl DBI question

From
Glyn Astill
Date:
> Run perl -V and see if the path is there for @INC. If it's there,
> check
> such things as permissions. If not, ponder deeply as to why this is
> so
> (as /usr/lib/perl5 is a standard path for perl in /usr) and if you
> can't
> fix it 'properly' you can work-around with the use of 'use lib'
> (see
> perldoc perlvar and search for @INC).

perl -V shows

  @INC:
    /etc/perl
    /usr/local/lib/perl/5.8.8
    /usr/local/share/perl/5.8.8
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.8
    /usr/share/perl/5.8
    /usr/local/lib/site_perl

Should the subdirectory DBD be in there? Perl was setup using apt.


      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com



Re: OT - pg perl DBI question

From
CaT
Date:
On Tue, Jan 29, 2008 at 04:45:48AM -0800, Glyn Astill wrote:
> Should the subdirectory DBD be in there? Perl was setup using apt.

How are you using it and what's your DBI db connect line?

I'm about to go to sleep so if I don't reply it'll be because I'm
unconcious. :)

--
    "To the extent that we overreact, we proffer the terrorists the
    greatest tribute."
        - High Court Judge Michael Kirby

Re: OT - pg perl DBI question

From
Glyn Astill
Date:
well its using the pgsql_replication_check.pl, which does:

----------------------
use Pg;
use Getopt::Std;

our ($opt_h, $opt_d, $opt_p, $opt_U, $opt_w, $opt_c) = '';
my ($conn, $res, $status, @tuple);
my $query = 'SELECT * FROM replication_status' ;
my @rep_time;
---------------------------------------

But the error I ge t is:

an't locate Pg.pm in @INC (@INC contains: /etc/perl
/usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
/usr/local/lib/site_perl .) at psql_replication_check.pl line 12.
BEGIN failed--compilation aborted at psql_replication_check.pl line
12.

So I assume it's not getting past the use Pg line as although it's
looking in /usr/lib/perl5 it's not going to look in
/usr/lib/perl5/DBD ??


--- CaT <cat@zip.com.au> wrote:

> On Tue, Jan 29, 2008 at 04:45:48AM -0800, Glyn Astill wrote:
> > Should the subdirectory DBD be in there? Perl was setup using
> apt.
>
> How are you using it and what's your DBI db connect line?
>
> I'm about to go to sleep so if I don't reply it'll be because I'm
> unconcious. :)
>
> --
>     "To the extent that we overreact, we proffer the terrorists the
>     greatest tribute."
>         - High Court Judge Michael Kirby
>



      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com



Re: OT - pg perl DBI question

From
CaT
Date:
On Tue, Jan 29, 2008 at 05:10:00AM -0800, Glyn Astill wrote:
> well its using the pgsql_replication_check.pl, which does:
>
> ----------------------
> use Pg;
...
> So I assume it's not getting past the use Pg line as although it's
> looking in /usr/lib/perl5 it's not going to look in
> /usr/lib/perl5/DBD ??

No. It's not using the DBI Pg. There's another module. A standalone one
that I believe it may be using. Under Debian this is available as
libpg-perl. Your OS/Distro may vary. If you don't have it available as a
package, check with CPAN.

Zzz...

--
    "To the extent that we overreact, we proffer the terrorists the
    greatest tribute."
        - High Court Judge Michael Kirby

Re: OT - pg perl DBI question

From
Richard Huxton
Date:
Glyn Astill wrote:
> well its using the pgsql_replication_check.pl, which does:
>
> ----------------------
> use Pg;
> use Getopt::Std;

>
> So I assume it's not getting past the use Pg line as although it's
> looking in /usr/lib/perl5 it's not going to look in
> /usr/lib/perl5/DBD ??

DBD::Pg is not the same as Pg.pm

perldoc DBD::Pg
perldoc Pg

I think it's libpg-perl that you want.

--
   Richard Huxton
   Archonet Ltd

Re: OT - pg perl DBI question

From
Colin Wetherbee
Date:
CaT wrote:
> On Tue, Jan 29, 2008 at 05:10:00AM -0800, Glyn Astill wrote:
>> well its using the pgsql_replication_check.pl, which does:
>>
>> ----------------------
>> use Pg;
> ...
>> So I assume it's not getting past the use Pg line as although it's
>> looking in /usr/lib/perl5 it's not going to look in
>> /usr/lib/perl5/DBD ??
>
> No. It's not using the DBI Pg. There's another module. A standalone one
> that I believe it may be using. Under Debian this is available as
> libpg-perl. Your OS/Distro may vary. If you don't have it available as a
> package, check with CPAN.

On Debian, you want libdbd-pg-perl.

cww@iron:~$ dpkg -S /usr/lib/perl5/DBD/Pg.pm
libdbd-pg-perl: /usr/lib/perl5/DBD/Pg.pm

To the OP: FYI, the DBI mailing lists can be found at the following URL.

http://dbi.perl.org/support/

Colin

Re: OT - pg perl DBI question

From
adam_pgsql
Date:
this looks to be using the Pg module rather than DBI + DBD::Pg. This
one i think:

http://www.cpan.org/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz

i think thats quite old now though....


On 29 Jan 2008, at 13:10, Glyn Astill wrote:

> well its using the pgsql_replication_check.pl, which does:
>
> ----------------------
> use Pg;
> use Getopt::Std;
>
> our ($opt_h, $opt_d, $opt_p, $opt_U, $opt_w, $opt_c) = '';
> my ($conn, $res, $status, @tuple);
> my $query = 'SELECT * FROM replication_status' ;
> my @rep_time;
> ---------------------------------------
>
> But the error I ge t is:
>
> an't locate Pg.pm in @INC (@INC contains: /etc/perl
> /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5
> /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
> /usr/local/lib/site_perl .) at psql_replication_check.pl line 12.
> BEGIN failed--compilation aborted at psql_replication_check.pl line
> 12.
>
> So I assume it's not getting past the use Pg line as although it's
> looking in /usr/lib/perl5 it's not going to look in
> /usr/lib/perl5/DBD ??
>
>
> --- CaT <cat@zip.com.au> wrote:
>
>> On Tue, Jan 29, 2008 at 04:45:48AM -0800, Glyn Astill wrote:
>>> Should the subdirectory DBD be in there? Perl was setup using
>> apt.
>>
>> How are you using it and what's your DBI db connect line?
>>
>> I'm about to go to sleep so if I don't reply it'll be because I'm
>> unconcious. :)
>>
>> --
>>    "To the extent that we overreact, we proffer the terrorists the
>>    greatest tribute."
>>        - High Court Judge Michael Kirby
>>
>
>
>
>      __________________________________________________________
> Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org/


Re: OT - pg perl DBI question

From
Colin Wetherbee
Date:
adam_pgsql wrote:
> this looks to be using the Pg module rather than DBI + DBD::Pg. This one
> i think:
>
> http://www.cpan.org/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz
>
> i think thats quite old now though....

Indeed, that's how it looks.  That would be in the libpg-perl package on
Debian.  In Lenny (testing), the latest version of that is 1:2.1.1-3.

Colin

Re: OT - pg perl DBI question

From
Colin Wetherbee
Date:
Colin Wetherbee wrote:
> CaT wrote:
>> On Tue, Jan 29, 2008 at 05:10:00AM -0800, Glyn Astill wrote:
>>> well its using the pgsql_replication_check.pl, which does:
>>>
>>> ----------------------
>>> use Pg;
>> ...
>>> So I assume it's not getting past the use Pg line as although it's
>>> looking in /usr/lib/perl5 it's not going to look in
>>> /usr/lib/perl5/DBD ??
>>
>> No. It's not using the DBI Pg. There's another module. A standalone one
>> that I believe it may be using. Under Debian this is available as
>> libpg-perl. Your OS/Distro may vary. If you don't have it available as a
>> package, check with CPAN.
>
> On Debian, you want libdbd-pg-perl.
>
> cww@iron:~$ dpkg -S /usr/lib/perl5/DBD/Pg.pm
> libdbd-pg-perl: /usr/lib/perl5/DBD/Pg.pm
>
> To the OP: FYI, the DBI mailing lists can be found at the following URL.
>
> http://dbi.perl.org/support/

Please ignore my noise.  The OP isn't using DBI, and libpg-perl is the
correct package for Pg.

Colin

Re: OT - pg perl DBI question

From
Martijn van Oosterhout
Date:
On Tue, Jan 29, 2008 at 01:30:04PM +0000, adam_pgsql wrote:
>
> this looks to be using the Pg module rather than DBI + DBD::Pg. This
> one i think:
>
> http://www.cpan.org/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz
>
> i think thats quite old now though....

In the one in this package:
http://packages.debian.org/lenny/libpg-perl

It's not old. It's kept reasonably up to date. It's more or less a shim
over the C library and has direct access to all its features, which is
not always possible with DBD:Pg.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

Attachment

Re: OT - pg perl DBI question

From
adam_pgsql
Date:
On 29 Jan 2008, at 13:39, Martijn van Oosterhout wrote:

> On Tue, Jan 29, 2008 at 01:30:04PM +0000, adam_pgsql wrote:
>>
>> this looks to be using the Pg module rather than DBI + DBD::Pg. This
>> one i think:
>>
>> http://www.cpan.org/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz
>>
>> i think thats quite old now though....
>
> In the one in this package:
> http://packages.debian.org/lenny/libpg-perl
>
> It's not old. It's kept reasonably up to date. It's more or less a
> shim
> over the C library and has direct access to all its features, which is
> not always possible with DBD:Pg.

ah sorry, i was just looking at the date on CPAN for
pgsql_perl5-1.9.0.tar.gz which says 04-Apr-2000.

Thanks for the more up to date info though.

adam

Re: OT - pg perl DBI question

From
Glyn Astill
Date:
Hi chaps,

Excellent, it was libpg-perl I needed.

Thanks

--- Richard Huxton <dev@archonet.com> wrote:

> Glyn Astill wrote:
> > well its using the pgsql_replication_check.pl, which does:
> >
> > ----------------------
> > use Pg;
> > use Getopt::Std;
>
> >
> > So I assume it's not getting past the use Pg line as although
> it's
> > looking in /usr/lib/perl5 it's not going to look in
> > /usr/lib/perl5/DBD ??
>
> DBD::Pg is not the same as Pg.pm
>
> perldoc DBD::Pg
> perldoc Pg
>
> I think it's libpg-perl that you want.
>
> --
>    Richard Huxton
>    Archonet Ltd
>



      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com



Re: OT - pg perl DBI question

From
David Fetter
Date:
On Tue, Jan 29, 2008 at 05:10:00AM -0800, Glyn Astill wrote:
> well its using the pgsql_replication_check.pl, which does:
>
> ----------------------
> use Pg;

I wouldn't trust that library or anything that depends on it if I were
you.  It's been unmaintained for a *very* long time.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Re: OT - pg perl DBI question

From
Andrew Sullivan
Date:
On Tue, Jan 29, 2008 at 04:24:05AM -0800, Glyn Astill wrote:
> Hi chaps,
>
> I'm trying yo run a perl script that uses DBI (Slonys
> psql_replication_check.pl to be precise) and I'm getting the error:
>
> Can't locate Pg.pm in @INC

Pg.pm isn't DBI.  It's the Pg Perl interface.

A

Re: OT - pg perl DBI question

From
Andrew Sullivan
Date:
On Tue, Jan 29, 2008 at 08:14:28AM -0800, David Fetter wrote:
>
> I wouldn't trust that library or anything that depends on it if I were
> you.  It's been unmaintained for a *very* long time.

Because code rusts when it's sitting around on a hard drive?

Pg.pm doesn't get much attention, I agree, but I've actually never run into
a (n undocumented) bug with it.  Also, for simple Perl access for
Postgres-dedicated use, DBI can be a little heavyweight.

A


Re: OT - pg perl DBI question

From
Geoffrey
Date:
David Fetter wrote:
> On Tue, Jan 29, 2008 at 05:10:00AM -0800, Glyn Astill wrote:
>> well its using the pgsql_replication_check.pl, which does:
>>
>> ----------------------
>> use Pg;
>
> I wouldn't trust that library or anything that depends on it if I were
> you.  It's been unmaintained for a *very* long time.

Are you speaking from personal experience, or just of the lack of
maintenance?

--
Until later, Geoffrey

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin

Re: OT - pg perl DBI question

From
Vivek Khera
Date:
On Jan 29, 2008, at 7:24 AM, Glyn Astill wrote:

> I'm trying yo run a perl script that uses DBI (Slonys
> psql_replication_check.pl to be precise) and I'm getting the error:
>
> Can't locate Pg.pm in @INC
>

It doesn't use DBI, it uses Pg.  At some point I posted patches to
convert it to DBI and DBD::Pg, but I don't know where those are
anymore as I don't use that code.


Re: OT - pg perl DBI question

From
"A.M."
Date:
On Jan 29, 2008, at 1:07 PM, Andrew Sullivan wrote:

> On Tue, Jan 29, 2008 at 08:14:28AM -0800, David Fetter wrote:
>>
>> I wouldn't trust that library or anything that depends on it if I
>> were
>> you.  It's been unmaintained for a *very* long time.
>
> Because code rusts when it's sitting around on a hard drive?
>
> Pg.pm doesn't get much attention, I agree, but I've actually never
> run into
> a (n undocumented) bug with it.  Also, for simple Perl access for
> Postgres-dedicated use, DBI can be a little heavyweight.
>

You mean other than the fact that it doesn't support the V3 protocol,
doesn't support escaping parameters, is a one-for-one wrapper for the
libpq from eight years ago (and has never been updated since), there
is a timing bug from 4 years ago still open (http://rt.cpan.org/
Public/Bug/Display.html?id=3177), and the docs include zingers like
"Starting with postgresql-6.5 it is required to use large objects
only inside a transaction"?

The postgresql from eight years ago is also quite rusty.

Cheers,
M

Re: OT - pg perl DBI question

From
Andrew Sullivan
Date:
On Tue, Jan 29, 2008 at 01:56:35PM -0500, A.M. wrote:
> The postgresql from eight years ago is also quite rusty.

No, it's not, which is my point.  If you don't need any of the features you
mention, and are aware of the limitations, there's nothing wrong with
using it.  The v2 protocol works, for instance, and for some applications
there's nothing wrong with it.

I wouldn't start a large project using Pg.pm right now, for sure, but I
think dismissing code you don't use on the basis that it's old is just
silly.  The reason we say "upgrade your postgresql" is not because it's old,
but because there are _known_ bugs in it, and those bugs eat data.

A


Re: OT - pg perl DBI question

From
"A.M."
Date:
On Jan 29, 2008, at 2:36 PM, Andrew Sullivan wrote:

> On Tue, Jan 29, 2008 at 01:56:35PM -0500, A.M. wrote:
>> The postgresql from eight years ago is also quite rusty.
>
> No, it's not, which is my point.  If you don't need any of the
> features you
> mention, and are aware of the limitations, there's nothing wrong with
> using it.  The v2 protocol works, for instance, and for some
> applications
> there's nothing wrong with it.
>
> I wouldn't start a large project using Pg.pm right now, for sure,
> but I
> think dismissing code you don't use on the basis that it's old is just
> silly.  The reason we say "upgrade your postgresql" is not because
> it's old,
> but because there are _known_ bugs in it, and those bugs eat data.
>

...and Pg.pm includes a serious security hole in the form of non-
existent query escaping which will never be fixed. Are we really
discussing the semantics of "rust"?

-M

Re: OT - pg perl DBI question

From
Andrew Sullivan
Date:
On Tue, Jan 29, 2008 at 03:16:41PM -0500, A.M. wrote:

> ...and Pg.pm includes a serious security hole in the form of non-
> existent query escaping which will never be fixed. Are we really
> discussing the semantics of "rust"?

It has never done that escaping.  No rust has occurred.  This is a problem
that's been there forever.  So I am not discussing the semantics, no.  But
we've certainly addressed the OP's question, and I guess this is rather off
topic for the list.

A

Re: OT - pg perl DBI question

From
Reece Hart
Date:
On Tue, 2008-01-29 at 13:28 -0500, Geoffrey wrote:
Are you speaking from personal experience, or just of the lack of
maintenance?

I'm guessing lack of maintenance... the SFPUG hasn't maintained David for a very long time. We think he lives at Casa Donde, but no one is really sure where that is.

-- 
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

Re: OT - pg perl DBI question

From
"Joshua D. Drake"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 29 Jan 2008 18:36:02 -0800
Reece Hart <reece@harts.net> wrote:
 
> I'm guessing lack of maintenance... the SFPUG hasn't maintained David
> for a very long time. We think he lives at Casa Donde, but no one is
> really sure where that is.

I thought last year was the year David started maintaining himself?

Joshua D. Drake

- -- 
The PostgreSQL Company: Since 1997, http://www.commandprompt.com/ 
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL SPI Liaison | SPI Director |  PostgreSQL political pundit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHn+oxATb/zqfZUUQRAlLdAJ4wF1MJDKaVic+QmX3rC+WTU/W95wCgkv/C
X4aDXoRyle3sIRh1MJyOwls=
=2O9q
-----END PGP SIGNATURE-----