I am trying to log into my table called acounts using MySQLdb in Python, but it does not work for me. I keep getting my message “Not Logged In”. Here is my code:
database = MySQLdb.connect("127.0.0.1", "root", "pswd", "Kazzah")
cursor = database.cursor()
cursor.execute("SELECT * FROM Accounts WHERE Email='%s' AND Password='%s'" % (_Email, _Password))
database.commit()
numrows = cursor.rowcount
if numrows == 1:
msg = "Logged In"
else:
msg = "Not Logged In"
cursor.close()
database.close()
What am I doing wrong? I am new to this so I hope I’ve done somewhat good. Thanks.
For some reason (I think because of using Terminal), when I would input the info, I would have to hit Enter. I believe when I would hit enter, the ‘\n’ was inserted and is what caused the numrows to return 0.
I placed
After _Email and _Password and now it works great! Now I have one other issue with something else, but nothing big. Thanks to everyone for helping!