May-01-2020, 12:29 AM
I have been reading a number of threads on how to accomplish this but for some reason it is not working.
I need to delete a specific row from a database. I am using a string variable from an entry widget to find the file I want to delete. The entry widget data is stored as variable Snippet_Name and the column to query is also named Snippet_Name.
The database has 7 columns but I am only using the 1 column for the query to find the file to delete the row. I have tried variations of DELETE with no success, even after reading countless threads and tutorials and looking at various examples (all use rowed).
I can delete the file using the rowid but if there is multiple files over time a user would not know the rowed so it needs to be looked up by the name entered in the Entry widget.
I am clearly missing something that I can't seem to find.
The code being used is:
I need to delete a specific row from a database. I am using a string variable from an entry widget to find the file I want to delete. The entry widget data is stored as variable Snippet_Name and the column to query is also named Snippet_Name.
The database has 7 columns but I am only using the 1 column for the query to find the file to delete the row. I have tried variations of DELETE with no success, even after reading countless threads and tutorials and looking at various examples (all use rowed).
I can delete the file using the rowid but if there is multiple files over time a user would not know the rowed so it needs to be looked up by the name entered in the Entry widget.
I am clearly missing something that I can't seem to find.
The code being used is:
def delete_code(): try: snippetname = Snippet_Name.get() sql_delete_query = ('DELETE FROM Code WHERE Snippet_Name = "?"', (snippetname)) c.execute(sql_delete_query) conn.commit() except: messagebox.showerror('PYSnippet', 'Failed to delete record')