sql封装小例
import MySQLdb
def executeSql(sql): print sql host = configOthers["sql_host"] port = int(configOthers["sql_port"]) user = configOthers["sql_user"] pwd = configOthers["sql_pwd"] db = configOthers["sql_db"] conn = MySQLdb.connect(host=host,port=port,user=user,passwd=pwd,db=db) cur = conn.cursor() cur.execute(sql) result = cur.fetchall() cur.close() conn.commit() conn.close() return result