Python reads and writes data to the Sqlite3 database by writing to an instance of Excel

Source: Internet
Author: User
This article mainly describes the Python implementation of read-write Sqlite3 database and write statistics to Excel, the Python for the Sqlite3 database read and Excel file-related operations skills, the need for friends can refer to the following

The example in this article describes how Python implements reading and writing Sqlite3 databases and writes statistical data to Excel. Share to everyone for your reference, as follows:


  src = ' f:\\log\\mha-041log\\rnd-log-dl.huawei.com\\test ' #  DST = sys.argv[2]  DST = ' f:\\log\\mha-041log\\ Rnd-log-dl.huawei.com\\test\\mha-041log.db ' #  dst_anylyzed = sys.argv[3]  dst_anylyzed = ' F:\\log\\ Mha-041log\\rnd-log-dl.huawei.com\\test\\mha-041log.xlsx ' cx = sqlite3.connect (DST)  Init_table_title (CX, startcoreapp_table)  Init_table_title (CX, startwechat_table)  init_table_title (CX, coreappjankframe_table)  Init_table_title (CX, wechatjankframe_table)  init_table_title (CX, otherapp_table)  os.path.walk (SRC, Visit_zipfile, CX)

Method of initializing the database:


def Init_table_title (C, work_table): Global Base_index Global Info_index c.execute (' DROP table I  F EXISTS ' + work_table);           C.execute (' CREATE TABLE ' + work_table + ' \ (Product text not null, \ Version text not NULL, \  The Imei text is not null, \ Date text is not null, \ Eventid text is not null, \ happentime text is not  NULL, \ FIELDNAME text not null, \ casename text not null) '); Return 
Related Article

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.