I have a program in which I will compare hash values generated from my code as the ones in my mysql database.
So, after generating the check values i have:
hash to be compared: 78ff0103440dcea01f36438a71bdf28f hash value from db: (('78ff0103440dcea01f36438a71bdf28f',),)
The hash value from the DB was output through using something like:
db_hash.fetchone()
that’s why it includes the ((”,),) symbols.
But I’ve tried appending the same symbols with the hash to be compared and it still wont equate properly.
Im baffled because it’s only supposed to be a simple compare through a
if hash == result:
do some code
else:
do some code
If you have an idea on what this is please answer 🙂
Python’s MySQL adapter returns rows as tuples of values – and in this case, you’re receiving a full result set of one row, with one column. To get the value of that, just do:
Of course, if your query was different (or returned no rows) this would throw an error. You should ideally be checking the number of rows returned (
len(dbResult)) first. The number of columns in each row will be consistent.