In [ ]:
# www.plus2net.com
# download updated script at https://www.plus2net.com/python/tkinter-sqlite-delete.php
import sqlite3
my_conn = sqlite3.connect('my_db.db')
###### end of connection ####

##### tkinter window ######
import tkinter  as tk 
from tkinter import * 
from tkinter import messagebox as msg
my_w = tk.Tk()
my_w.geometry("400x350") 
def my_show():
    r_set=my_conn.execute('''SELECT * from student LIMIT 0,10''');
    i=0 # row value inside the loop 
    for student in r_set: 
        for j in range(len(student)):
            e = Entry(my_w, width=10, fg='blue') 
            e.grid(row=i, column=j) 
            e.insert(END, student[j])
        e = Button(my_w, text='X',command=lambda d=student[0] : my_delete(d)) 
        e.grid(row=i, column=j+1)
        i=i+1
def my_delete(id):
    my_var=msg.askyesnocancel("Delete ?","Delete id:"+str(id),icon='warning',default='no')
    if my_var: # True if yes button is clicked
        r_set=my_conn.execute("DELETE FROM student WHERE id=" + str(id) );
        msg.showerror("Deleted ","No of records deleted = " + str(r_set.rowcount))
        my_conn.commit()
        my_show() # refresh the window with new records
my_show()  # open the window with record at the starting      
    
my_w.mainloop()