These Are The Records in Employee Table Before Delete: 34 - KAMALA - 55 - Female - PHD - 6000.0 - Professor - 02-05-1990
These Are The Records in Employee Table Before Delete: 34 - KAMALA - 55 - Female - PHD - 6000.0 - Professor - 02-05-1990
C:\sqlite3>sqlite3 my3.db
1|ram|22|male|MTECH|30000.0|Assistant professor|02-02-1988
5|suma|30|female|MTECH|1000.0|Assistant professor|03-01-1999
9|GAYATHRI|23|female|BE|10000.0|Assistant professor|02-01-2016
123|SACHIN|18|male|MTECH|20000.0|Assistant professor|01-01-2003
34|KAMALA|55|female|PHD|6000.0|professor|02-05-1990
38|KAVERI|55|female|PHD|100000.0|professor|02-03-1990
78|SUHAS|27|male|BE|7000.0|Assistant professor|03-08-2017
576|gfh|18|female|MTECH|123.0|Assistant professor|01-01-2000
63|shivu|30|male|MTECH|30000.0|Assocaite professor|02-02-2013
678|padamini|26|female|BE|3000.0|Assistant professor|05-01-2019
900|RAGHU|26|male|BE|10000.0|Assistant professor|03-04-2001
11111|JHKJ|19|male|SSLC|2000.0|peon|01-01-2000
777|HKLJL|19|female|BE|1000.0|Assistant professor|01-01-2000
#python program to delete a record from employee table and display the rcords before and after
#delete using GUI
import sqlite3
def raise_frame(frame):
#when delete button is selected second frame is raised which allows user to delete
#record. First select empid from spinbox and press mouse right button
if frame==f1:
frame.tkraise()
l1=Label(f1,text="select Empid").place(x=50,y=200)
v1=IntVar()
le=[]
conn = sqlite3.connect('c:\sqlite3\my3.db')
c = conn.cursor()
for i in r1:
le.append(int(i[0]))
conn.close()
te=tuple(le)
s1=Spinbox(f1,font=('Arial',14),value=te, textvariable=v1,width=3)
s1.place(x=200,y=200)
def show1(self):
eid=int(v1.get())
conn1 = sqlite3.connect('c:\sqlite3\my3.db')
c1 = conn1.cursor()
r3=c1.execute(sql,(eid,))
conn1.commit()
if c1.rowcount==1:
conn1.close()
#once spinbox item is selected press right button to invoke show1 fucnction
s1.bind("<Button-3>",show1)
if frame==f:
frame.tkraise()
if frame==f2:
frame.tkraise()
l10.place(x=50,y=10)
t=Text(f2,width=70,height=15,wrap=WORD)
t.place(x=200,y=100)
conn3 = sqlite3.connect('c:\sqlite3\my3.db')
c3 = conn3.cursor()
for i in r:
t.insert(END,i)
t.insert(END,'\n')
conn3.close()
#main program create three frame
r=Tk()
r.geometry('1000x1000')
f=Frame(r,width=1000,height=1000)
f.place(x=20,y=20)
f1=Frame(r,width=1000,height=1000)
f1.place(x=20,y=20)
f2=Frame(r,width=1000,height=1000)
f2.place(x=20,y=20)
#on clicking update button it opens new form where by selecting empid salary of that employee can be
updated
#on clicking display button it display button display the current records in employee table
b=Button(f,text="DELETE",font=('Arial',20,'bold'),fg='red',command=lambda:raise_frame(f1)).place(x=40
0,y=50)
b1=Button(f,text="DISPLAY",font=('Arial',20,'bold'),fg='red',command=lambda:raise_frame(f2)).place(x=
400,y=150)
b2=Button(f1,text="BACK",font=('Arial',20,'bold'),fg='red',command=lambda:raise_frame(f)).place(x=55
0,y=550)
b3=Button(f2,text="BACK",font=('Arial',20,'bold'),fg='red',command=lambda:raise_frame(f)).place(x=55
0,y=550)
raise_frame(f)
r.mainloop()
Output:
1|ram|22|male|MTECH|30000.0|Assistant professor|02-02-1988
5|suma|30|female|MTECH|1000.0|Assistant professor|03-01-1999
9|GAYATHRI|23|female|BE|10000.0|Assistant professor|02-01-2016
123|SACHIN|18|male|MTECH|20000.0|Assistant professor|01-01-2003
38|KAVERI|55|female|PHD|100000.0|professor|02-03-1990
78|SUHAS|27|male|BE|7000.0|Assistant professor|03-08-2017
576|gfh|18|female|MTECH|123.0|Assistant professor|01-01-2000
63|shivu|30|male|MTECH|30000.0|Assocaite professor|02-02-2013
678|padamini|26|female|BE|3000.0|Assistant professor|05-01-2019
900|RAGHU|26|male|BE|10000.0|Assistant professor|03-04-2001
11111|JHKJ|19|male|SSLC|2000.0|peon|01-01-2000
777|HKLJL|19|female|BE|1000.0|Assistant professor|01-01-2000