#!/usr/bin/python2 # import MySQL module import MySQLdb import socket import sys db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") cursor = db.cursor() cursor.execute("SHOW tables") result = cursor.fetchall() ops=["REPAIR","OPTIMIZE","ANALYZE"] for row in result: ctable=row[0] for op in ops: print op,ctable cmd= "%s table %s" %(op,ctable) cursor.execute(cmd)