Re: problem connecting client to a postgresSQL server

From: Gurudutt <guru(at)indvalley(dot)com>
To: "darwin" <dharval(at)digitelone(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: problem connecting client to a postgresSQL server
Date: 2001-11-09 15:07:35
Message-ID: 12040189525.20011109203735@indvalley.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)indvalley(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gabriel Fernandez 2001-11-09 15:45:43 Precision problems with float8
Previous Message Nick Fankhauser 2001-11-09 14:39:22 Re: Help installing PGSQL 7.1 on Linux