how to connect postgresql database

From: sudheer raghav <yelukur(at)yahoo(dot)com>
To: rob(at)y2k(dot)state(dot)il(dot)us, tgl(at)sss(dot)pgh(dot)pa(dot)us, matt(at)summersault(dot)com, pgsql-general(at)postgresql(dot)org
Subject: how to connect postgresql database
Date: 2005-01-19 11:55:58
Message-ID: 20050119115558.13217.qmail@web30405.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hi,
> am new to Perl.
> How to connect postgresql database with perl ? here
>is the Perl code follows:
> #!/usr/bin/perl
> use CGI qw(:standard);
> use DBI;
> use strict;
>
> print "Content-type: text/html\n\n";
> use CGI::Carp qw/fatalsToBrowser/;
> $query = new CGI;
> print $query->header;
>
>$dbh = DBI->connect("dbi:Pg:dbname=test", "postgres",
>"", {AutoCommit => 1, Rais
>eError => 1});
>
>if($query->param("submit") eq "save") {
>$sth = $dbh->prepare("SELECT ip_add from firewall
>where $source_add ='10.0.0.10'");
>} else {
> print "error";
> }
>
>if(!defined($sth)) {
> print "ERROR: Unable to execute database query:
>$DBI::errstr\n";
> exit;
>}
> $sth->execute;
>
>
>$sth->finish;
>
>print $query->start_html("FIREWALL");
>
>print <<"EOF";
> <HTML>
> <BODY>
> print "<center><H1>FIREWALL</H1></center>\n";
> print "IP Adress:";
> print $query->popup_menu(-name=>'IP Adress',
>
>-Values=>['10.0.0.1','10.0.0.2','10.0.0.3','10.0.0.4',10.0.0.5,10.0.0.6],
> );
>
> print "Source IP Adress:";
> print $query->textfield('numeric');
> print "Destination IP Adress:";
> print $query->textfield('Dest');
> print $query->radio_group(-name=>'Disable Enable',
> -Values=>['Disable','Enable'],
> );
>
>
> print "<P><center>$query->submit('Action','save');
>
> print
>$query->submit('Action','cancel')</center></P>";
> </BODY>
> </HTML>
>EOF
> print $query->end_html;
> $dbh->disconnect;
> exit(0);
>

=====
Y.SUDHEER RAGHAV+919440521140


__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-01-19 12:20:49 Re: Multiline plpython procedure
Previous Message Wayne Brown <fwbrown@bellsouth.net> 2005-01-19 11:45:44 Re: Will someone please be a vote taker.