title: Read MySQL blob in python
body: <p>Hi I have a problem with type after I get blob from my query, here is the code</p>
  <pre><code>conn = MySQLdb.connect(&quot;mysqlblah&quot;, &quot;user&quot;, &quot;pass&quot;, &quot;db&quot;)
  
  cursor = conn.cursor()
  
  data = []
  queryString = &quot;SELECT * FROM contentindex where tag LIKE '&quot; + contentType + &quot;%'&quot;
  cursor.execute(queryString)
  
  rows = cursor.fetchall()
  columns = [t[0] for t in cursor.description]
  for row in rows:
      jsonRow = {}
      i = 0
      for column in columns:
          if column == &quot;created&quot;:
              jsonRow[column] = str(row[i])
          elif column == &quot;icon&quot;:
              icon = row[i]
              print icon
              jsonRow[column] = &quot;data:image/(jpg);base64,&quot; + base64.b64encode(icon.getvalue())
          else:
              jsonRow[column] = row[i]
          i = i + 1
      data.append(jsonRow)
  </code></pre>
  <p>This prints <code>&lt;_io.BytesIO object at 0x01667810&gt;</code> and then throws <code>'str' object has no attribute 'getvalue'</code> exception.</p>
  <p>I'm pounding for days on this problem, any help will be greatly appreciated</p>