'How do I get data from an entry in tkinter

from tkinter import *
import pyautogui as pg
import mysql.connector
from tkinter import Button
tkWindow = Tk()  
tkWindow.geometry('400x150')  
tkWindow.title('Tkinter Login Form')
mydb = mysql.connector.connect(host = "localhost", user = "root", passwd= "the", database = "login")
mycursor = mydb.cursor()




def check():
    state = False
    state1 = False
    mycursor.execute("SELECT username FROM logs")
    username = mycursor.fetchall()
    x = username
    mycursor.execute("SELECT password FROM logs")
    password = mycursor.fetchall()
    y = password
    for row in x:
        if(m in row):
            state = True
            break

    for row in y:
        if(n in row):
            state1 = True
            break
    if(state and state1 == True):
        pg.alert("Allowed")


 

label = Label(tkWindow, text="Username").grid(row=0, column=0)
username = StringVar()
m = Entry(tkWindow, textvariable=username).grid(row=0, column=1)

label2 = Label(tkWindow,text="Password").grid(row=1, column=0)  
password = StringVar()
n = Entry(tkWindow, textvariable=password).grid(row=1, column=1)
def no():
    check()

loginButton = Button(tkWindow, text="Login",command = no).grid(row=4, column=0)

tkWindow.mainloop()

Hi, so this is my code, it gets the username and password from a MYSQL database, the terminal version of this code worked and the problem is in the entry box section.

I have been programming for 5 hours and really need the fixed code, so please post a copy of the fixed code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source