I have created a registration page which uploads data to SQL Server but I have no idea how to write the code to authenticate the entered username and password in the login page. def login_successful(): if usernameEntry.get()=='' or passwordEntry.get()=='' or passwordEntry.get()=='Password': messagebox.showerror("Error", "Missing details") else: connection = pyodbc.connect('DRIVER={SQL Server};' + 'SERVER=LAPTOP-D74DF11D;' + 'Database=userdata;' + 'Trusted_Connection=Yes') connection.autocommit = YES connection.execute("IF EXISTS (SELECT * FROM Data Where username = f"'{usernameEntry.get()}'" and pass = f"'{passwordEntry.get()}'")") messagebox.showinfo("Success!", "Account Successfully Created!") I have tried the if exist query, to identify if the entered username and password are correct but my efforts resulted to none. Continue reading...