Skip to content

Instantly share code, notes, and snippets.



Created Nov 16, 2011
What would you like to do?
Bash script to generate a html file describing all tables in a database
#Change your db username, password & database name
if [ -f ~/Desktop/db_schema.html ]; then
rm ~/Desktop/db_schema.html
for i in `mysql -B -N -uroot -proot dbname -e 'show tables;'`; do
echo "<a href='#$i'>$i</a><br />" >> /tmp/$$.nav.html
echo "<a name='$i'></a>" >> /tmp/$$.tables.html
echo "<h2>$i</h2>" >> /tmp/$$.tables.html
mysql --html --column-names -uroot -proot dbname -e "desc $i;" >> /tmp/$$.tables.html
echo -n >> /tmp/$$.tables.html
cat /tmp/$$.nav.html /tmp/$$.tables.html > ~/Desktop/db_schema.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.