1
I want to do the following:
Create a function with a quantity parameter, thus causing the value of the parameter to subtract with a value from a table field:
Example: sell(5), this 5 will subtract with table quantity field.
The closest I got was:
def vender(self, nome, quantidade):
consulta = 'UPDATE OR IGNORE Produtos SET quantidade = quantidade-1'
self.cursor.execute(consulta, ())
self.conexao.commit()
Only in this case it decreases 1 in 1.
Hi, Voce is subtracting quantity-1, you have to first check the quantity and subtract the amount from the result.
– Ernesto Casanova
Hello, the mode that G.Bittencourt posted below solved the problem, only now it is giving conflict with the registration function, when I will register a product of the following error....self.cursor.execute(query, (name,category,value,quantity)) sqlite3.Operationalerror: near "?": syntax error
– Ayrton Gomes
I was able to solve it, I only had to open and close parentheses within VALUES ? ,? ,? ,? resulting in VALUES(?,?,??)... Thank you very much
– Ayrton Gomes