title: python 2.x zlib.decompress data from mysql
body: <p>Can I decompress data in python that compressed from mysql?</p>
  
  <p>mysql 5.6</p>
  
  <pre><code>select to_base64(compress("test"));
  </code></pre>
  
  <p>result from mysql</p>
  
  <pre><code>BAAAAHicK0ktLgEABF0BwQ==
  </code></pre>
  
  <p>python to decompress</p>
  
  <pre><code>&gt;&gt;&gt; import zlib
  &gt;&gt;&gt; import base64
  &gt;&gt;&gt; s = "BAAAAHicK0ktLgEABF0BwQ=="
  &gt;&gt;&gt; zlib.decompress(base64.b64decode(s))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  zlib.error: Error -3 while decompressing data: incorrect header check
  </code></pre>
  
  <p>I checked the <a href="http://docs.python.org/2/library/zlib.html#zlib.decompress" rel="nofollow">zlib manual</a> I don't know why it's giving the error?</p>
  
  <p><strong>Solution</strong>
  I found solution from my friend.</p>
  
  <pre><code>ss = base64.b64decode(s)
  zlib.decompress(ss[4:])
  </code></pre>