-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprac_10a.py
61 lines (47 loc) · 1.79 KB
/
prac_10a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import mysql.connector
from tkinter import *
from tkinter import messagebox
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database ="collage"
)
mycursor = mydb.cursor()
root = Tk()
root.geometry('750x600')
root.title("Registration Form")
f_name=StringVar()
address=StringVar()
def database():
name1=f_name.get()
addre=address.get()
mycursor.execute('INSERT INTO customers (name,address) VALUES(%s, %s)',(name1,addre))
messagebox.showinfo("success", "You have Registration Successfully")
mydb.commit()
label_0 = Label(root, text="Registration form",width=20,font=("bold", 20))
label_0.place(x=250,y=10)
label = Label(root, text="Name",width=15,anchor=W,font=("bold", 10))
label.place(x=80,y=80)
entry_0 = Entry(root,textvar=f_name,width=40)
entry_0.place(x=280,y=80,)
label_1 = Label(root, text="Address",width=15,anchor=W,font=("bold", 10))
label_1.place(x=80,y=130)
entry_1 = Entry(root,textvar=address,width=40)
entry_1.place(x=280,y=130)
def display():
mycursor.execute("SELECT name,address FROM customers")
catch = mycursor.fetchall()
for item in catch:
textin = item
output.insert(END,textin)
output.insert(END,"\n")
messagebox.showinfo("success", "Data Successfully Fetched")
def clr():
output.delete('1.0', END)
output=Text(root,width=40,height=8,font=('Time 20 bold'),fg="black")
output.place(x=75,y=220)
Button(root, text='Submit',width=15,bg='brown',fg='white',command=database).place(x=312,y=180)
Button(root, text='Display',width=10,bg='brown',fg='white',command=display).place(x=275,y=500)
Button(root,text='Clear',command=clr,width=10,bg='brown',fg='white').place(x=400,y=500)
root.mainloop()