I am querying a MySQL database in python and selecting a boolean value -- so the response from MySQL is either the string 'True' or 'False'. I would like to execute further code based on the boolean value from MySQL.
E.g.
data = 'False' # assume this is what was returned by MySQL.
if data:
print 'Success' #really this would be where I would execute other if True.
else:
print 'Fail' #really this would be where I would execute other code if False
But I can't do this because
if data:
will always return True
So how do I convert the string that MySQL is returning into a boolean in python?
Currently I have:
data = 'False' # assume this is what was returned by MySQL.
if data == 'True':
print 'Success'
else:
print 'Fail'
I believe there must be a better way to do this in python -- likely there is something simple I am missing.