I'm trying to make an access control system based on pincode entry. I'm having issues on how to check if the pincode entered is present in the MySQL database.
Below snippet works, it asks for the pincode, and can successfully parse it with the database when the pincode only contains numbers.
pin_inp = raw_input("Enter PIN: ")
cursor.execute("SELECT COUNT(1) FROM members WHERE pincode = " + pin_inp + ";")
But I would like to have alphanumerical pincodes though. I thought I could just create the pincode column as VARCHAR
and enter alphanumerical pincodes, but then it will not successfully parse with the database. With an alphanumerical entry I get this error:
_mysql_exceptions.OperationalError: (1054, "Unknown column '7988DB' in 'where clause'")
So I have a few rows in the members
table for testing, some with numerical values in column pincode
, some with alphanumerical values. When I run above code, the numerical entries are OK, but the alphanumerical values throw the 1054 error.