将tkinter树视图中的数据插入sqlite数据库

2024-05-16 10:42:50 发布

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

我正在用Python用Tkinter创建一个桌面程序,它是一个简单的晚餐程序,您可以选择客户想要的产品并将其保存到一个表号中,然后对每个表号的总值求和。你知道吗

The front page looks like this。 很抱歉是葡萄牙语的,但是

  • “comanda”是指“表号”
  • “Quantidade”是指“金额”
  • “Quantidade”是指“金额”

在我的sqlite数据库中,我有四列'Comanda'、'Status'、'Valor'、'Produtos',第一列有15个表号,第二列是判断表是活动的还是非活动的,第三列是客户机选择的所有产品的总和,第四个应该给我一个客户选择的所有产品名称的列表,但是我不能将每个表中选择的所有产品插入数据库中的一个单元格,到目前为止我得到的是:

def cmd():
  variavel1 = ncomandaE.get() #gets the table number
  variavel2 = "Aberto" #change the status to active

  for row in addprod.get_children():
     variavel4 = addprod.item(row)['values'][1] #gets the second column of the treeview which is the products name

     lite=c.execute("UPDATE comanda SET produtos = ? WHERE comandas = ?", 
     (str(variavel4), variavel1),)

它没有给我一个错误,但只给我的最后一个产品,客户选择。你知道吗

有人能帮帮我吗?你知道吗

提前谢谢。你知道吗


Tags: the程序数据库get客户产品金额row