Skip to content

Instantly share code, notes, and snippets.

@ashfame ashfame/gist:1370753
Created Nov 16, 2011

Embed
What would you like to do?
Bash script to generate a html file describing all tables in a database
#!/bin/bash
#Change your db username, password & database name
if [ -f ~/Desktop/db_schema.html ]; then
rm ~/Desktop/db_schema.html
fi
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
done;
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.