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

##### tkinter window ######
import tkinter  as tk 
from tkinter import * 
####### end of connection ####

my_w = tk.Tk()
my_w.geometry("400x200") 

# add one Label 
l1 = tk.Label(my_w,  text='Enter Student ID: ', width=25 )  
l1.grid(row=1,column=1) 

# add one text box
t1 = tk.Text(my_w,  height=1, width=4,bg='yellow') 
t1.grid(row=1,column=2) 

b1 = tk.Button(my_w, text='Show Details', width=15,bg='red',
    command=lambda: my_details(t1.get('1.0',END)))
b1.grid(row=1,column=4) 

my_str = tk.StringVar()
# add one Label 
l2 = tk.Label(my_w,  textvariable=my_str, width=30,fg='red' )  
l2.grid(row=3,column=1,columnspan=2) 

my_str.set("Output")

def my_details(id):
    try:
        val = int(id) # check input is integer or not
        try:    
            q="SELECT * FROM student WHERE id= "+id
            my_cursor=my_conn.execute(q)
            data_row=my_cursor.fetchone()
            my_str.set(data_row)
        except sqlite3.Error as my_error:
            print("error: ",my_error)
    except:
        my_str.set("Check input")
my_w.mainloop()