0

Empty entries filled in MySQL tables (Python + Tkinter)

Having a problem of data entry in MySQL. At the time of entry it don't take any value from me or user. And one more thing I want to add multiple pages. But how can I make button to submit the value and direct to page 2. please if anyone know then please me. Thank you

Here he the table which is completely empty.

from tkinter import * 
import mysql.connector
from PIL import Image,ImageTk

m=Tk()
button_bg='#FF9200'
button_fg='#fff'
active_button_fg='#FF9200'
active_button_bg='#fff'


def tkinter_setup():
    m.geometry('1024x720')




def database_connectivity():

    FullName=StringVar()
    CollegeName=StringVar()
    Email = StringVar()
    Password=IntVar()
    CGPA= IntVar()

    fullName=FullName.get()
    collegeName=CollegeName.get()
    email=Email.get()
    password=Password.get()
    cgpa=CGPA.get()

    
    mydb = mysql.connector.connect(host="localhost", user="root", passwd="ashu12",database='mySchool')
    cursor=mydb.cursor()
    cursor.execute('CREATE TABLE IF NOT EXISTS Student (FullName TEXT,CollegeName TEXT,Email TEXT,Password INT,CGPA INT)')
    cursor.execute('INSERT INTO Student (FullName,CollegeName,Email,Password,CGPA) VALUES(%s,%s,%s,%s,%s)',(fullName,collegeName,email,password,cgpa))
    mydb.commit()

def page2():
    entry7 = Entry(m,width=70)
    entry7.place(x=0,y=30)
    entry7.insert(0,'Full Name')
    m.mainloop()



def page1():

    Image_open=Image.open("1.png")
    image=ImageTk.PhotoImage(Image_open)
    logo=Label(m,image=image)
    logo.place(x=0,y=0,bordermode="outside")

    entry1 = Entry(m,textvar='FullName',font="Ubuntu")
    entry1.place(height=45,width=397,x=145,y=154)

    entry1 = Entry(m,width=42,textvar='Collegename',font="Ubuntu")
    entry1.place(height=45,width=397,x=145,y=210)

    entry1 = Entry(m,width=42,textvar='Email',font="Ubuntu")
    entry1.place(height=45,width=397,x=145,y=266)

    entry1 = Entry(m,width=42,textvar='Password',font="Ubuntu")
    entry1.place(height=45,width=397,x=145,y=322)    
    
    entry1 = Entry(m,width=42,textvar='CGPA',font="Ubuntu")
    entry1.place(height=45,width=397,x=145,y=377)
    
    
    button = Button(m,text='Registration' , bg=button_bg,foreground=button_fg,activebackground=active_button_bg,activeforeground=active_button_fg,command=page2 )
    button.place(height=47, width=399 ,x=144,y=476)
    m.mainloop()





tkinter_setup()
database_connectivity()
page1()
page2()
Community
  • 1
  • 1
Dark Knight
  • 31
  • 1
  • 6
  • I don't know if this is the problem, but certainly _a_ problem is calling `mainloop` more than once. You should never call `mainloop` more than once. The other problem seems to be that you're calling `database_connectivity()` before the user has a chance to enter any data. – Bryan Oakley Oct 10 '19 at 15:02
  • First you have to understand [Event-driven programming](https://stackoverflow.com/a/9343402/7414759), read [Is this bad programming practice in tkinter?](https://stackoverflow.com/questions/25454065/is-this-bad-programming-practice-in-tkinter) and [Best way to structure a tkinter application](https://stackoverflow.com/a/17470842/7414759) – stovfl Oct 10 '19 at 16:10

0 Answers0