Dean Hamstead wrote:
im looking for something that will spit out something human readable
from mysql, describing all the tables
something that will connect to mysql and spit out a html data dictionary
Attached is a GLP* I use for that purpose. For plain text output:
list-mysql5-database.bash {dbname}
and for HTML that really needs use a style sheet:
list-mysql5-database.bash {dbname} --HTML
cheers
rickw
*GLP = Grungey Little Programme whipped up without any QA :)
--
_________________________________
Rick Welykochy || Praxis Services
Natural foods can be harmful. Look at all the
people who die of natural causes.
-- anon
#!/bin/bash
if [ $# -lt 1 ]; then
mysql -e 'show databases' 1>&2
echo 1>&2 "use: $0 database [--HTML]"
exit 1
fi
database=$1
outformat=--table
if [ "$2" = "--HTML" ]; then html=1; outformat=--html; else unset html; fi
if ! mysql "$database" -e 'show tables' >/dev/null; then
mysql -e 'show databases' 1>&2
echo 1>&2 "Could not connect to database '$database'"
exit 1
fi
if [ ! -z $html ]; then echo "<h1>Schema for database $database</h1><h2>List of
tables</h2><pre>"; else echo -e "Schema for database $database\n"; fi
mysql "$database" --table -e 'show tables' | grep -v '^Tables'
if [ ! -z $html ]; then echo "<br></pre>"; else echo; fi
for table in `mysql "$database" -B -e 'show tables' | grep -v '^Tables'`; do
nrows=`mysql "$database" -B -e "select count(*) as THE_COUNT from
$table" | grep -v THE_COUNT`
if [ ! -z $html ]; then echo "<br><br><hr><br><h2>Table: $table -
$nrows rows</h2>"; else echo "Table $table: $nrows rows"; echo; fi
mysql "$database" $outformat -e "desc $table"
if [ -z $html ]; then echo; fi
done
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html