Re: prob with PERL/Postgres

From: Thomas Good <tomg(at)admin(dot)nrnet(dot)org>
To: Kate Collins <klcollins(at)wsicorp(dot)com>
Cc: kris(at)grinz(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: prob with PERL/Postgres
Date: 2001-08-06 21:14:50
Message-ID: Pine.LNX.4.05.10108061713200.29068-100000@admin.nrnet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 6 Aug 2001, Kate Collins wrote:

> I use the Perl DBI module to connect to a postgres data base on the local
> system. I don't specify the host name. This is the syntax I use to connect to
> the data base:
>
> use DBI;
>
> $dbname = "foo";
> $connstr = "dbi:Pg:dbname=$dbname";
> $dbh = DBI->connect($connstr);

Kate, he uses a diff module by the same author (Edmund Mergl) but with
a very diff syntax. The advantage of the DBI - Kris, if you're interested -
is that the syntax is much like ESQL/C and the code is much more portable.
For example I use DBI to access both pg and oracle.

Cheers,
Tom

> Kristopher Yates wrote:
>
> > PERL SNIPPET:
> >
> > # build arrays from file (OMITTED)
> >
> > use Pg;
> > $dbhost='127.0.0.1';
> > $dbname='mpact';
> > #$connstr="dbname=$dbname";
> > $connstr="host=$dbhost dbname=$dbname";
> > $conn = Pg::connectdb($connstr);
> >
> > #more code related to date omitted
> >
> > $result=$conn->exec($sql);
> > (PGRES_COMMAND_OK eq $result->resultStatus)
> > or die $conn->errorMessage;
> >
> > WHY DO I GET PQsendQuery() -- There is no connection to the
> > backend. I have tried leaving host blank, using IP 127.0.0.1 and
> > hostname localhost. This script should work - the problem is
> > something with postgres but I dont know what. Any ideas out
> > there? Thanks, Kris
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
>
>
> --
> =================================================
> Katherine (Kate) L. Collins
> Senior Software Engineer/Meteorologist
> Weather Services International (WSI Corporation)
> 900 Technology Park Drive
> Billerica, MA 01821
> EMAIL: kcollins(at)wsi(dot)com
> PHONE: (978) 262-0610
> FAX: (978) 262-0700
> http://www.intellicast.com
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--------------------------------------------------------------------
SVCMC - Center for Behavioral Health
--------------------------------------------------------------------
Thomas Good tomg@ { admin | q8 } .nrnet.org
Programmer/Analyst Phone: 718-354-5528
Residential Services Mobile: 917-282-7359
--------------------------------------------------------------------
/* Die Wahrheit Ist Irgendwo Da Draussen... */
--------------------------------------------------------------------

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-08-06 21:39:15 Re: prob with PERL/Postgres
Previous Message Josh Berkus 2001-08-06 20:55:43 Re: Re: Data type confusion