from Tkinter import *
def addData():
conn=sqlite3.connect('deedinfo.db')
cur=conn.cursor()
cur.execute("create table if not exists deedsort(bkpage text,grantor text,grantee text,action text)")
#Get data from GUI
bookpage=(thebookpage.get())
seller=(theseller.get())
buyer=(thegrantee.get())
action=(theaction.get())
clearGUI()
#Inserts data into table. Make sure and use a list to insert values! very important!
cur.execute("insert into deedsort values (?,?,?,?)",([bookpage,seller,buyer,action]))
conn.commit() #Saves the data
myrows=cur.execute("select * from deedsort")
def listData():
conn=sqlite3.connect('deedinfo.db')
cur=conn.cursor()
myrows=cur.execute("select * from deedsort")
for row in myrows:
print("---------------------------")
print "Book page: " , row[0]
print "Grantor: ",row[1]
print "Grantee: ",row[2]
print "Action taken: ",row[3]
def finddeed():
con=sqlite3.connect("deedinfo.db")
cur=con.cursor()
deedbookpage = thebookpage.get()
clearGUI()
cur.execute("select * from deedsort")
rows = cur.fetchall()
for row in rows:
if row[0]== str(deedbookpage):
print "\nBook and Page: ", row[0]
print "Grantor: ",row[1]
print "Grantee: ",row[2]
print "Action Taken: ",row[3]
def clearGUI():
thebookpage.delete(0,END)
theseller.delete(0,END)
thegrantee.delete(0,END)
theaction.delete(0,END)
root=Tk()
btn=Button(root,text="List table",command=listData)
btn.pack()
btn3=Button(root,text="find deed",command=finddeed)
btn3.pack()
btn2=Button(root,text="Add to table",command=addData)
btn2.pack()
labl=Label(root,text="Book and page").pack()
thebookpage = Entry()
thebookpage.pack()
labl2=Label(root,text="Grantor").pack()
theseller = Entry()
theseller.pack()
labl3=Label(root,text="Grantee").pack()
thegrantee=Entry()
thegrantee.pack()
labl3=Label(root,text="Action?").pack()
theaction=Entry()
theaction.pack()
root.mainloop()