On Thu, Nov 08, 2001 at 07:26:18PM -0600, Mark Browne wrote:
> So far I have got the web form <--->Perl part working; Yippie for CGI.
> The cgi-lib code makes this falling-off-a-log simple.
Yup.
> Now for the Perl<--->database part.
> I am actually working on it tonight.
> It seem that DBI is the way to go.
> If I understand this correctly it works the same for most databases.
Yup. DBI rocks.
> I downloaded it last night and am working through the documentation.
>
> A little working sample code would be nice.
This won't work for you right off, since database names have been
changed to protect the guil^Winnocent, but it should be enough to
point you in the right direction.
---
#!/usr/bin/perl -wT
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Pg:host=SERVERNAME;dbname=DBNAME",
"DBUSER", "DBPASSWORD")
|| die "Failed to connect: $!\n";
my $qry = $dbh->prepare("select * from some_table");
$qry->execute;
while (my @row = $qry->fetchrow_array) {
print @row;
}
$dbh->do("delete from some_table");
---
You can omit the host=SERVERNAME part if you're connecting to a local
database.
It's that easy.
--
When we reduce our own liberties to stop terrorism, the terrorists
have already won. - reverius
Innocence is no protection when governments go bad. - Mr. Slippery