#coding:gb18030
import cx_Oracle
import xlsxwriter
import time
import sys
reload(sys)
sys.setdefaultencoding("gb18030")
con = cx_Oracle.connect("user/[email protected]")
cursor = con.cursor()
query1 = cursor.execute(""" select OL_NBR,OL_ID,To_char(OL_SO_DATE,‘YYYY-MM-DD hh24:mi:ss‘) ,CO_NBR,MIN_CO_ID,MAX_CO_ID,PROD_ID,PROD_SPEC_ID,PROD_NAME,ORDER_TYPE_NAME,OWNER_ID,OWNER_NAME,AREA_ID,AREA_NAME,STAFF_ID,STAFF_NUMBER,STAFF_NAME,CHANNEL_ID,CHANNEL_NAME,To_char(CO_DATE,‘YYYY-MM-DD hh24:mi:ss‘),To_char(INSTALL_DATE,‘YYYY-MM-DD‘),CO_FIRST_YYSJ,LXR,LXDH,LAST_STATE_CD,LAST_STATE_NAME,JRH,BDH,JX_ID,JX_NAME,FGS_ID,FGS_NAME,CPLX,DDLX,BSS_ORDER_FZT,E_BS,ORDER_ID,To_char(DISPL_DATE,‘YYYY-MM-DD hh24:mi:ss‘) ,TZ_GDH,TZ_GD_GW,ZYJ_DZ,GEOGRAPHY_LOC_ID,BZ_DZ,YCYY,RETURN_REMARKS,FFBZ,JFE,CO_GRP_ID,LINE_CO_ID,LINE_JRH,LINE_ORDER_ID,LINE_INTE_ORDER_ID,LINE_TZ_GD_GW,FKID,FKLX,ZHBZ from fzt_dd """ )
#取出数据库字段信息
title = [i[0] for i in query1.description]
workbook = xlsxwriter.Workbook(‘Expenses01.xlsx‘, {‘constant_memory‘: True})
worksheet = workbook.add_worksheet()
print time.ctime()
data = cursor.fetchall()
print time.ctime()
worksheet.write_row(0, 0, title)
#按列写入xlsx文件
for row, row_date in enumerate(data):
worksheet.write_row(row+1, 0, row_date)
print time.ctime()
cursor.close()
con.close()
workbook.close()
附件列表
时间: 2024-10-07 13:52:26