0
I have a product registration program with everything working only I lack the update, I can update edit the data in the table and in the bank but it is not working right.
It edits all the data and not just the data I want. If I type the name and leave the rest blank it changes the name and deletes the other fields.
So my question is what should I change in this function for it to work by editing only the selected field?
def editarProd(self):
self.banco = sqlite3.connect('Vendas.db')
self.cursor = banco.cursor()
query = "SELECT * FROM Produtos"
result = self.banco.execute(query)
for row_number in enumerate(result):
if row_number[0] == self.listaprodutos.currentRow():
data = row_number[1]
Nome = data[0]
Nome2 = self.produtotext.text()
Quant2 = self.estoquetext.text()
Valor2 = self.precocustotext.text()
Preco2 = self.precovendatext.text()
Forn2 = self.fornecedorcomboBox.currentText()
self.banco.execute(f"UPDATE Produtos SET Nome='{Nome2}', Quant='{Quant2}', Valor='{Valor2}', Preco='{Preco2}', Forn='{Forn2}' WHERE Nome='{Nome}'")
self.banco.commit()
self.LoadDatabase()
if you want to see the full code is all commented
Did you not see that it was already solved? Look at the answers has nothing outstanding or too wide.
– Daniel Heringer