Respect the lowercase and uppercase letters when getting a mysql data [duplicate]
I would like to know how can i respect lowercase/uppercase letters when getting an information from a mysql server(phpmyadmin exactly), here is the working code, i made a register/login script and i would like to add it.
def checkLogin():
global windowOpened
getmail = emailEntry.get()
getpass = passwordEntry.get()
sql = "SELECT * FROM users WHERE email = %s AND password = %s"
mycursor.execute(sql, [(getmail), (getpass)])
results = mycursor.fetchall()
if results:
for i in results:
logWindow.destroy()
messagebox.showinfo("Succes", "Logged in succesfully!")
windowOpened = 0
else:
messagebox.showinfo("Error", "Email or password are incorrect.")
if i enter the password full uppercase, it is still correct, even if the password is full lowercase.
Solution 1:
You should use BINARY
to make your query case-sensitive:
SELECT * FROM users WHERE email = BINARY %s AND password = BINARY %s