zoukankan      html  css  js  c++  java
  • 按分类查找缺陷并输出到EXCEL

    import pymysql,xlwt
    def export_excel(table_name):
    host,user,passwd,db='192.168.1.10','root','zentao_123','zentao'
    coon=pymysql.connect(host=host,user=user,passwd=passwd,db=db,port=3306,charset='utf8')
    cur=coon.cursor() #建立游标
    sql='''SELECT
    type,
    count( * ) AS 激活数量,
    sum( IF ( severity = 1, 1, 0 ) ) AS 1级数量,
    sum( IF ( severity = 2, 1, 0 ) ) AS 2级数量,
    sum( IF ( severity = 3, 1, 0 ) ) AS 3级数量,
    sum( IF ( severity = 4, 1, 0 ) ) AS 4级数量
    FROM
    zt_bug
    WHERE
    product = '189'
    AND STATUS = 'active'
    GROUP BY
    type'''
    cur.execute(sql)#执行sql
    fileds=[filed[0] for filed in cur.description]#所有字段
    all_data=cur.fetchall()#所有值
    print(all_data)
    book=xlwt.Workbook()
    sheet=book.add_sheet('sheet1')
    for col,filed in enumerate(fileds):
    sheet.write(0,col,filed)
    row = 1
    for data in all_data:
    for index, datacol in enumerate(data): # 控制列
    sheet.write(row, index, datacol)
    row = row+ 1
    book.save('%s.xls' %table_name)
    export_excel('zentao.zt_bug') # 导出excel

    https://www.cnblogs.com/jiajunplyh/p/12150433.html
  • 相关阅读:
    [HNOI2014]江南乐
    烦人的数学作业(数位dp)
    http2.0请求springboot接口
    01背包动态规划
    坑点总结
    [机房测试] 堆石子
    [机房测试] 出租车
    [机房测试] 下棋
    [机房测试] number
    [CSP-S2019] 树的重心
  • 原文地址:https://www.cnblogs.com/ruijie/p/14958869.html
Copyright © 2011-2022 走看看