Python implements the sqlite3 database read and write statistical data into Excel method example, pythonsqlite3

Source: Internet
Author: User

Python implements the sqlite3 database read and write statistical data into Excel method example, pythonsqlite3

This example describes how to read and write data from the sqlite3 database in Python and write data into Excel. We will share this with you for your reference. The details are 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)

Database initialization method:

def init_table_title(c, work_table):  global base_index  global info_index  c.execute('DROP TABLE IF EXISTS ' + work_table);  c.execute('CREATE TABLE ' + work_table + ' \           (Product TEXT NOT NULL, \           Version TEXT NOT NULL, \           Imei TEXT NOT NULL, \           Date TEXT NOT NULL, \           Eventid TEXT NOT NULL, \           HappenTime TEXT NOT NULL, \           FIELDNAME TEXT NOT NULL, \           CASENAME TEXT NOT NULL)');  return

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.