Python Forum

Full Version: Deleting a row in SQlite3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am creating a function to delete a row in SQlite3. It works, but the program just update what I've deleted when I close and run it again. There is anyway that I can do it without closing and opening again?
    def exclude (self, *args, **kwargs):
        result = tkinter.messagebox.askyesno('Provedor', 'Deseja realmente deletar?', icon = 'warning')
        if result == True:
            deletar = "DELETE FROM inventory WHERE Name = ?"
            c.execute(deletar,(self.Name_e.get(),))
            conn.commit()
(Jul-22-2020, 02:31 PM)SmukasPlays Wrote: [ -> ]It works, but the program just update what I've deleted when I close and run it again
What do you mean? Does the row get deleted or not? One thing that is not correct is the following:
conn.comit()
It should be:
conn.commit()
(Unless of course comit() is a function or method you added yourself.)
(Jul-22-2020, 05:46 PM)ibreeden Wrote: [ -> ]
(Jul-22-2020, 02:31 PM)SmukasPlays Wrote: [ -> ]It works, but the program just update what I've deleted when I close and run it again
What do you mean? Does the row get deleted or not? One thing that is not correct is the following:
conn.comit()
It should be:
conn.commit()
(Unless of course comit() is a function or method you added yourself.)

Oh, I didn't noticied it, thanks. I wrote commit() now but it still doesn't work. I mean that, the row is just deleted when I close the program and open it again. If i search for the row that I've deleted before closing, it will appear again.
You need to post a minimal, complete program that demonstrates the problem. Not seeing the other code means we can't help diagnose the problem.