in reply to Reading DB

I have never used SQL2000 before but found it fairly simple for MySQL. Here are some subroutines that I use to manage an sql database on a webserver.
sub GetDatabases { my @tempdbname; my @databases2; my @databases = DBI->data_sources("mysql"); for my $x(0..$#databases) { @tempdbname = split(/:/,$databases[$x]); push @databases2, $tempdbname[$#tempdbname]; } return @databases2; } sub GetTables { my $database = shift; my @tables2; my $datasource = "dbi:mysql:dbname=$database;host=localhost;"; my $dbh = DBI->connect($datasource,'dbuser','password' ,{PrintErro +r => 0}) or return @tables2; my $statement = "SHOW TABLES"; my $sth = $dbh->prepare($statement); my $rc = $sth->execute(); if($rc ne "0E0") { my $tables = $sth->fetchall_arrayref; for my $xx(0..$#{$tables}) { push @tables2,$tables->[$xx][0]; } } return @tables2; } sub GetFields { my $database = shift; my $table = shift; my @fields; my $counter = 0; my $test; my $datasource = "dbi:mysql:dbname=$database;host=localhost;"; my $dbh = DBI->connect($datasource,'dbuser','password'); my $statement = "DESCRIBE $table;"; my $sth = $dbh->prepare($statement99); my $rc = $sth->execute(); while($test = $sth->fetchrow_hashref) { $counter++; for my $t(keys %{$test}) { # field field info $fields[$counter]{$t} = $test->{$t}; } } return @fields; }
I know it may not be very pretty or efficient but it is effective and simple. I'll leave the implementation up to you.