在Excel中导入mysql表

我在Python的noob,但我需要在python中使用xlwt将MySQL表导出到.xls文件。 我成功地从这里使用示例导出表

http://ryrobes.com/featured-articles/using-xlwt-and-python-to-export-an-oracle-dataset-to-excel-python-simple-etl-part-2/

但如果在MySQL表中有两个以上的列,excel和MySQL中的表列顺序不匹配。

这是代码的一部分:

from xlwt import * import sys import MySQLdb table_name='student' sql_select="SELECT * FROM %s"%table_name conn1 =MySQLdb.connect(host='localhost',user='root',passwd='',db='test') cu_select=conn1.cursor(MySQLdb.cursors.DictCursor) try: cu_select.execute(sql_select) except MySQLdb.Error, e: errInsertSql = "Insert Sql ERROR!! sql is==>%s" %(sql_select) sys.exit(errInsertSql) result_set = cu_select.fetchall()' 

我试图打印result_set,发现不匹配从这里开始。 谁能帮我。

如果您希望有组织的订单使用行,则按字母顺序或按升序排列表。