utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# author: 'zkx'
# date: '2018/3/11'
# Desc:从数据库中导出数据到...excel数据表中
#已封装,可以直接使用,只需更改sql语句即可
import xlwt
import MySQLdb
def export(host,user,password,dbname,table_name...MySQLdb.connect(host,user,password,dbname,charset='utf8')
cursor = conn.cursor()
#时间戳相减,转换为时分秒 导出到excel...时间格式要统一("%Y-%m-%d %H:%i:%S"),不然导出到excel为null
#concat(floor((lasto/1000-first/1000)/3600),"小时",floor(mod...print count
# 重置游标的位置
cursor.scroll(0,mode='absolute')
# 搜取所有结果
results = cursor.fetchall()
# 获取MYSQL里面的数据字段名称