python遍历数据库表及其相关表操作.
#!/usr/bin/python
import MySQLdb
import getopt
import sys
from datetime import datetime
conf_host = '127.0.0.1'
conf_port = 3306
conf_user = 'root'
conf_pass = ''
conf_db = 'information_schema'
conf_bind_db = 'mydns'
def main():
db_bind = MySQLdb.connect(host = conf_host, port = conf_port, user = conf_user, passwd = conf_pass, db = conf_bind_db)
cursor_bind = db_bind.cursor()
db = MySQLdb.connect(host = conf_host, port = conf_port, user = conf_user, passwd = conf_pass, db = conf_db)
cursor = db.cursor()
file = open("output.txt","w")
cursor.execute("select table_name from tables where table_name regexp'rg_' and table_schema ='" + conf_bind_db + "