MySQL Database export xls-Custom

Source: Internet
Author: User

Scripting with Python, one-click Export of SQL statement execution results to an XLS table, each statement results in a tab page

V1, running locally

File list:

bm.py

bm_sqlcon.py

sql.py

xls.py

Need to install a third-party module

easy_install mysql-connector-python
pip install xlwt

实现了结果格式转换,时长计算使用百纳秒到小时:分:秒:帧。设置单元格日期格式,转换数字为汉字说明,设置列宽。
语句未做交互

def s_t(bnm):
    bnm=int(bnm)
    miao=bnm//10**7
    #print(miao)
    fen=miao//60
    xs=miao//3600
    dual=(bnm/10**7-miao)*25
    dual=round(dual)
    miao=miao%60
    fen=fen%60
    fh=str(xs)+‘:‘+str(fen)+‘:‘+str(miao)+‘:‘+str(dual)
    return fh



v2 版本可以考虑增加网页交互

MySQL Database export xls-Custom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.