title: Query in function is not executing
body: <p>I am trying to create a button where you can delete a record selected using trv.bind. I can select fine as I already tried using print to display the OID when selecting but when I add a delete function, it does nothing and gives me no errors. From my understanding I am selecting the specific row through the OID but my function does not delete. The query is not executing.</p>
  <p>I made a sample code that mirrors mine.</p>
  <pre><code>import tkinter
  from tkinter import *
  from tkinter import ttk, LabelFrame, StringVar
  import tkinter.messagebox
  import sqlite3
  
  #cursor
  conn = sqlite3.connect('newtest.db')
  
  #cursor is needed for sql functions
  c = conn.cursor()
  
  top = tkinter.Tk()
  
  q = StringVar()
  t1 = StringVar()
  t2 = StringVar()
  
  #this grabs each ID
  def getrows(event):
      rowid = trv.identify_row(event.y)
      item = trv.item(trv.focus())
      t1.set(item['values'][0])
      t2.set(item['values'][1])
  
  def pdelete():
      oid = t1.get()
      query = &quot;DELETE FROM products WHERE oid = &quot;+oid
      c.execute(query)
  
      conn.commit()
  
  def update(show):
      trv.delete(*trv.get_children())
      for i in show:
          trv.insert(&quot;&quot;, 'end', values=i)
  
      return show
  
  
  conn.commit()
  
  def query_database():
      query = &quot;SELECT oid, pdesc from products&quot;
      conn = sqlite3.connect('newtest.db')
      c = conn.cursor()
      c.execute(query)
      show = c.fetchall()
  
      return show
  
  box4 = LabelFrame(top, text=&quot;Products Summary&quot;)
  box4.pack (fill=&quot;both&quot;, expand=&quot;yes&quot;, padx=20, pady=10)
  
  trv = ttk.Treeview(box4, column=(1,2), show=&quot;headings&quot;, height=&quot;20&quot;)
  style=ttk.Style(trv)
  style.configure('Treeview', rowheight=20)
  
  trv.pack(side=LEFT)
  trv.heading(1, text=&quot;Product ID&quot;)
  trv.heading(2, text=&quot;Product Description&quot;)
  
  
  conn = sqlite3.connect('newtest.db')
  query = &quot;SELECT oid, pdesc from products&quot;
  c.execute(query)
  show = c.fetchall()
  update(show)
  
  #deletebutton
  btn6 = ttk.Button(box4, text='Delete', command=pdelete)
  btn6.pack(side=RIGHT)
  
  #select
  trv.bind('&lt;Double 1&gt;', getrows)
  
  top.title(&quot;deletetest&quot;)
  top.geometry(&quot;1500x1200&quot;)
  top.mainloop()
  </code></pre>