python操作sqlite——資料庫匯出Excel報表——2020.12.25
阿新 • • 發佈:2020-12-25
python操作sqlites
一丶資料庫匯出Excel報表
import sqlite3 from xlsxwriter.workbook import Workbook workbook = Workbook('output.xlsx') worksheet = workbook.add_worksheet() # 傳入資料庫路徑 conn=sqlite3.connect('jwxt.db') c=conn.cursor() mysel=c.execute("select * from Grade where JXBID='JXB001'") for i, row in enumerate(mysel): for j, value in enumerate(row): worksheet.write(i, j, value) workbook.close()