We never stop looking ... ...for a better way

Welcome to Woods Applied Technologies
Saturday, September 04 2010 @ 02:23 AM MDT

Test Perl DBI Module

research librarythis script tests the perl dbi module#!/usr/local/bin/perl

use DBI;

print "Content-type:text/html\n\n";
#if printing to web
#you dont need the port number if its the default

$db_handle = DBI->connect("dbi:mysql:database=mysql;host=localhost:3306;user=user;password=whatever")
or die "Couldn't connect to database: $DBI::errstr\n";

$sql = "SELECT * FROM user";
$statement = $db_handle->prepare($sql)
or die "Couldn't prepare query '$sql': $DBI::errstr\n";

$statement->execute()
or die "Couldn't execute query '$sql': $DBI::errstr\n";
while ($row_ref = $statement->fetchrow_hashref())
{
print "User <b>$row_ref-></b> has privileges on <b>$row_ref-></b>.<br>\n";
}

$db_handle->disconnect();

Story Options

Trackback

Trackback URL for this entry: http://www.watcorp.com/trackback.php?id=20050625091943589

No trackback comments for this entry.
Test Perl DBI Module | 1 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Test Perl DBI Module
Authored by: cary on Saturday, June 25 2005 @ 02:06 PM MDT
another good battery of tests
http://www.cs.wcupa.edu/~rkline/Perl/perl-db-tests.html