#!/usr/bin/env python # # Simple utility to generate a mysqladmin script to create DBs # # This python script will generate the following statements: # mysqladmin -u admin -h localhost -pYourOwnPassword create course101_01_db # to # mysqladmin -u admin -h localhost -pYourOwnPassword create course101_49_db # # rename this file from createDB.txt to createDB.py # usage: ./create.py # it will create a shell file call createdb.sh to run ########################################################################### import sys import os def main(): a = 1 f = open("createdb.sh",'w') max1 = 10 ########################################################### # change this following number when there are more databases max2 = 50 ############################################################ DB = "course101_" mess = "mysqladmin -u admin -h localhost -pYourOwnPassword create " 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()