代码拉取完成,页面将自动刷新
# -*- coding:utf-8 -*-
#导入数据库数据
import sqlite3
#打开数据库
con = sqlite3.connect("money.db")
con.text_factory = lambda x:str(x, 'gb2312')
#取得游标
cu = con.cursor()
#查询
cu.execute("select Time, Name, Amount, TypeName from Income, IncomeType where IncomeType.TypeID == Income.TypeID")
#获取结果
data = cu.fetchall()
#关闭数据库
con.close()
#显示结果
#print(data[10])
#print(cu.description[2][0])
#print(len(data))
#将数据写入csv文件
import csv
with open("money.csv", "w") as csvfile:
writer = csv.writer(csvfile)
item = []
for i in range(4):
item.append(cu.description[i][0])
writer.writerow(item)
writer.writerows(data)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。