#! /usr/bin/python
# drop-all-tables.py
# to drop all tables from a DB without dropping the DB

import sys
import MySQLdb

# connect to the MySQL server

try:
	conn = MySQLdb.connect (host = "localhost",
			user = "",
			passwd = "",
			db = "")
except MySQLdb.Error, e:
	print "Error %d: %s" % (e.args[0], e.args[1])
	sys.exit (1)

# create the animal table and populate it

try:
	cursor = conn.cursor ()
# 	cursor.execute ("DROP TABLE IF EXISTS animal")
	cursor.execute("""show tables; """)
	result =cursor.fetchall()
	
	for i in range(len(result)): 
		cursor.execute("drop table " + str(result[i][0]) + ";")
		
		
except MySQLdb.Error, e:
	print "Error %d: %s" % (e.args[0], e.args[1])
	sys.exit (1)

conn.close ()
sys.exit (0)

