Re: problem connecting client to a postgresSQL server - Mailing list pgsql-general

From Gurudutt
Subject Re: problem connecting client to a postgresSQL server
Date
Msg-id 12040189525.20011109203735@indvalley.com
Whole thread Raw
In response to Re: problem connecting client to a postgresSQL server  (GB Clark II <gclarkii@vsservices.com>)
Responses General question about DBI/DBD
List pgsql-general
Hello GB,

Install DBI modules for PgSQL and start working

HERE IS SAMPLE PROGRAM

---------------------- PROGRAM STARTS HERE -----------------------
#! <your path to perl>

use DBI;

# DATABASE HANDLE DECLARATION
my $dbHandle;


# QUERY VARIABLE DECLARATION
my $dbQuery;

# QUERY VARIABLE HANDLE DECLARATION
my $dbQueryHandle;

# VARIABLE TO STORE THE HASH REFS
my $dbRow;


# ESTABLISH  CONNECTION TO THE PG-SQL AND CONCERNED DATABASE
 $dbHandle=DBI->connect( "dbi:Pg:dbname=testdb", "username", "password") || die $DBI::errstr ;


# QUERY A SIMPLE TABLE
$dbQuery="select testcode,testname from testtab";

# PREPARE THE QUERY
$dbQueryHandle=$dbHandle->prepare($dbQuery) || die $dbHandle->errstr;

# EXECUTE THE QUERY
 $dbQueryHandle->execute || die $dbHandle->errstr;

# FETCH A ROW

if($dbRow=$dbHandle->fetchrow_hashref())
{
   # PRINT THE FETCHED RESULT SET
   print "\n TESTCODE: $dbRow->{testcode}";
   print "\n TESTNAME: $dbRow->{testname}";
}

 $dbQueryHandle->finish || die $dbHandle->errstr;

 $dbHandle->disconnect || die $DBI::errstr;

--------------------PROGRAM ENDS----------------------
if you're connecting to some remote machine, just add the IP address
in the DBI connect statement.

Hope I have helped u a bit


--
Best regards,
 Gurudutt                            mailto:guru@indvalley.com

Life is not fair - get used to it.
Bill Gates




Friday, November 09, 2001, 3:53:23 PM, you wrote:

GCI> On Friday 09 November 2001 03:22, darwin wrote:
>> Hi!! Im Darwin a student from DATA COllege San Fernando
>> Pampanga, Philppines. I am a new memeber in your mailing
>> list. Hope you could accomodate me.
>>
>> I just want to consult anyone out there who could help me in
>> my problem regarding "HOW TO CONNECT A CLIENT TO A
>> POSTGRESSQL SERVER USING PERL ?". I am having a hard since
>> August and its bugging me cause I could not finish my
>> thesis.
>>
>> I'm hopping that a generous mind could share something about
>> it.


pgsql-general by date:

Previous
From: Tielman J de Villiers
Date:
Subject: Re: Help installing PGSQL 7.1 on Linux
Next
From: Francisco Reyes
Date:
Subject: Re: Disable Transaction - plans ?