python sqlite插入

2024-04-25 22:47:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是python3tkinter和sqlite 我在tkinterText Widget中有数据,然后我需要将其拆分并保存在数据库表中这是我的代码

data = txtReceipt.get("4.0" ,"end")

 for line in data.splitlines()[2:-2]:

     no = line.split()[2:3]
     name = line.split()[1:2]
     price = line.split()[3:4]
     series = line.split()[:1]
     print(no)
     c.execute("INSERT INTO  billed_items(item_name,billed_qty,price,item_bill_series) VALUES(?,?,?,?)",(name),(no),(price),(series))
     conn.commit()

但是我收到了这个错误信息TypeError: function takes at most 2 arguments (5 given) 需要帮忙吗 这里也是当我试图读回文本小部件的时候

    su=c.execute("SELECT * FROM billed_items")
    for row in su:
            text = str(row)
            txtReceipt.insert("end",str(row[0])+"  "+str(row[1])+'\t\t'+str(row[2])+'\t'+"  "+str(row[3])+"\n")

在那里它只读表中的最后一行我不知道为什么他不能读所有的行


Tags: nonameinforexecutedatalineprice