python 格式化数据表

# coding=utf-8
import pymysql
import os

host="localhost"
user="root"
password="root"
db="exam"

exceptTables=["exam_question_type",'exam_function','exam_admin_group']

conn = pymysql.connect(host=host,user=user,password=password,database=db,charset="utf8")

with conn.cursor() as cursor:
    cursor.execute('show tables')
    rs = cursor.fetchall()
    for row in rs:
        cmd = "TRUNCATE "
        cmd += row[0]
        #print cmd
        if(row[0] in exceptTables):
            continue
        cursor.execute(cmd)

 

posted on 2017-08-15 11:01  正义的伙伴!  阅读(256)  评论(0编辑  收藏  举报

导航

//增加一段JS脚本,为目录生成使用