title: Working with MySQL booleans in python
body: <p>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. </p>
  
  <p>E.g.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>But I can't do this because</p>
  
  <pre><code>if data:
  </code></pre>
  
  <p>will always return True</p>
  
  <p>So how do I convert the string that MySQL is returning into a boolean in python?</p>
  
  <p>Currently I have:</p>
  
  <pre><code>data = 'False'  # assume this is what was returned by MySQL.
  if data == 'True':
    print 'Success'
  else:
    print 'Fail'
  </code></pre>
  
  <p>I believe there must be a better way to do this in python -- likely there is something simple I am missing.</p>