title: How to delete record from tkinter treeview to apply the changes in sqlite3
body: <p>Am trying to delete record displayed in <code>tkinter treeview</code> by using the <code>tree.selection()</code> method. I want the selected <code>row</code> in the <code>treeview</code> selected to also be deleted from the <code>sqlite3</code>db also but when i select <code>row</code> to be deleted i received this error </p>
  
  <blockquote>
    <p>_tkinter.TclError: Item I not found</p>
  </blockquote>
  
  <p>i found this <a href="https://www.google.com.gh/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwijypiv3JjZAhXBDMAKHcEbCuMQrAIIKygAMAA&amp;url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F48625242%2Ftkinter-tclerror-item-0-not-found&amp;usg=AOvVaw0H4eeLObajlNlh-m_O2OC7" rel="nofollow noreferrer">link</a> on the site but i doesn't answer my talent.</p>
  
  <pre><code>from tkinter import ttk
  import tkinter as tk
  import sqlite3
  
  
  def connect():
      conn = sqlite3.connect("TRIAL.db")
      cur = conn.cursor()
      cur.execute("CREATE TABLE IF NOT EXISTS profile(id INTEGER PRIMARY KEY, 
  First TEXT, Surname TEXT)")
      conn.commit()
      conn.close()
  
  
  def Delete():
      selected_item = tree.selection()[0]
  
      print(selected_item)  # it prints the selected row id
  
      conn = sqlite3.connect("TRIAL.db")
      cur = conn.cursor()
      cur.execute("DELETE FROM profile WHERE id=?", (selected_item,))
      conn.commit()
  
      for b in selected_item:
          tree.delete(b)
  
      conn.close()
  
  
  connect()  #  this to create the db
  
  root = tk.Tk()
  root.geometry("400x400")
  
  tree= ttk.Treeview(root, column=("column1", "column2", "column3"), 
  show='headings')
  tree.heading("#1", text="NUMBER") 
  tree.heading("#2", text="FIRST NAME")
  tree.heading("#3", text="SURNAME")
  tree.pack()
  
  
  b2 = tk.Button(text="DELETE FROM PARTICULAR DATA TREEVIEW AND SQLITE3", 
  command=Delete)
  b2.pack(side=tk.BOTTOM)
  
  root.mainloop()
  </code></pre>