#!/usr/bin/perl # # DBCInfo Query Based on Cannonical Perl DBI connection to Mysql. ############################################################################## use DBI; $host = "Host Address"; # = "localhost", the server your are on. $db = "My User Name"; # your username (= login name = account name ) $user = $db; # your Database name is the same as your account name. $pwd = "Password"; # Your account password # connect to the database. print(__PACKAGE__ . ':' . __LINE__ . ":Connecting...\n"); $dbh = DBI->connect( "DBI:Teradata:$host", $user, $pwd) or die "Connecting : $DBI::errstr\n "; print(__PACKAGE__ . ':' . __LINE__ . ":Connected.\n"); $sql = "SELECT * FROM DBC.DBCInfo"; # executing the SQL statement. $sth = $dbh->prepare($sql) or die "preparing: ",$dbh->errstr; $sth->execute or die "executing: ", $dbh->errstr; print "content-type: text/html\n\n"; # one of the functions to retrieve data from the table results # check perldoc DBI for more methods. while ($row = $sth->fetchrow_hashref) { foreach(sort(keys(%$row))) { print("$_:\[$row->{$_}\]\n"); } }