Re: [INTERFACES] Perl Interface

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: robert_hiltibidal_at_cms08405(at)ccmailgw(dot)state(dot)il(dot)us
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Perl Interface
Date: 1999-06-22 18:43:02
Message-ID: Pine.GSO.3.96.SK.990622223258.27398A-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Robert,

have you seen DBI/DBD perl interface to PostgreSQL ?
I'd recommend you to try it.
Your script looks like (not tested):
------------------------------------
#!/usr/bin/perl
use DBI;
my $dbname = 'test';
my $query = "Select username,password,knickname,emailaddy,forward,ip,date from temp";
$dbh = DBI->connect("dbi:Pg:dbname=$dbname") or die $DBI::errstr;
my $sth = $dbh->prepare ( $query ) or die "Can't prepare statement: $DBI::errstr\n\t$query";
$sth->execute() or die "Can't execute statement: $DBI::errstr\n\t$query";
while ( my @ary = $sth->fetchrow() ) {
print join("\|",@ary),"\n";
}
$sth->finish or die $DBI::errstr;

Regards,

Oleg

On Tue, 22 Jun 1999 robert_hiltibidal_at_cms08405(at)ccmailgw(dot)state(dot)il(dot)us wrote:

> Date: Tue, 22 Jun 99 12:46:33 -0600
> From: robert_hiltibidal_at_cms08405(at)ccmailgw(dot)state(dot)il(dot)us
> To: pgsql-interfaces(at)postgreSQL(dot)org
> Subject: [INTERFACES] Perl Interface
>
>
> Afternoon,
>
> Something that's been driving me a little buggy maybe someone Out
> There can shed some light...
>
> We use postgres for user management on linux systems. Nothing fancy
> about the fields, just username,password,lastname,firstname etc.
>
> Traditionally I've used the shell psql function:
> @exec = `psql -A -d users -t -q -c "Select * from temp"`;
>
> Weeellll now I'm running into server timeouts on the box. The
> adminmstration box does see a fair amount of load. We use sql
> extensively and consequently we ahve a large number of cron jobs that
> fire up psql shells. I had thought using the methods found in pg would
> help. I am planning to port our applications over to C but... that's a
> several month job. I'm looking for a quick fix here to buy me some
> time. The other side of that is C is not my preferred language of
> choice... I do pascal and perl.
>
> I am not clear yet as how to navigate multiple rows on the recordset
> return using the pg method. Ideally I want to put all the results into
> an array like this:
> username|password|lastname
> marty|next|Robinson
> mel|foreman|Johnson
>
> The <$ret = $result->fetchrow> function only returns a portion of the
> row.
>
> I have created a lttle subroutine using the getvalue method that
> iterates thru each row and pushes it into an array. This will work for
> now. However I am curious, is there another, more simpler method to
> accomplish this?
>
> Thanks,
>
> -Rob
>
> ############################
> # Subroutine #
> ############################
>
>
>
>

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

  • Perl Interface at 1999-06-22 18:46:33 from robert_hiltibidal_at_cms08405

Browse pgsql-interfaces by date

  From Date Subject
Next Message robert_hiltibidal_at_cms08405 1999-06-22 18:46:33 Perl Interface
Previous Message Steffen Zimmert 1999-06-22 18:38:12 JDBC:Using Large Objects