Re: perl Pg module and result status

From: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: perl Pg module and result status
Date: 2000-09-21 01:24:17
Message-ID: 20000920212417.B274@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 20, 2000 at 07:27:40PM -0400, Edward Q. Bridges wrote:
> i can't seem to locate the reference to the documentation
> you mention in the perldoc for DBD::Pg, can you reference
> it?

I believe he is using straight Pg - the perl interface to Postgres.
AFAIK, that's independant of DBI::Pg, which is the Postgres
driver for DBI.

I agree with you, however: I've found DBD::Pg quite a bit easier
to work with than Pg. It also gives you the possibility of
moving your code to another database with relatively small
changes.

If you don't mind me commenting on your code:

> use DBI;
> $user = '';
> $pass = '';
> $dburl = ''; # should be: dbi:Pg:dbname=[your database name]
> $db = DBI->connect($dburl, $user, $pass, {AutoCommit=>0} )
> or die "Can't connect to db";

Is there a reason you're not using constants? e.g.

use constant DB_USER => 'foo';
use constant DB_PASSWD => 'qwerty';

You might also want to add the "$DBI::errstr" to the error message
on a connection failure.

(Sorry, I just couldn't resist nit-picking :D)

HTH,

Neil

--
Neil Conway <neilconway(at)home(dot)com>
Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc
Encrypted mail welcomed

Is uniformity [of religion] attainable? Millions of innocent men, women, and
children, since the introduction of Christianity, have been burnt, tortured,
fined, imprisoned; yet we have not advanced one inch towards uniformity.
-- Thomas Jefferson, "Notes on Virginia"

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Fernando Lozano 2000-09-21 01:43:17 Re: import CVS file
Previous Message Neil Conway 2000-09-21 01:14:26 Re: Re: Large Objects