#!/usr/bin/env python # # generate a mysqladmin shell script to drop DBs # # To automate the dropping of multiple MySQL DBs # usage: ./dropDB.py #################################################################### import sys import os def main(): a = 1 f = open("dropdb.sh",'w') max1 = 10 ############################################################ # Change this number to any higher number you desire to use max2 = 41 ############################################################ DB = "class_" mess = "echo Y | mysqladmin -u admin -h localhost -pYourOwnPassword drop " while a < max1: tmp = mess + DB + '0' + str(a) + '_db' f.write(tmp) f.write("\n") a=a+1 while a < max2: tmp = mess + DB + str(a) + '_db' f.write(tmp) f.write("\n") a=a+1 f.close() main()