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