By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

MySQLdb blob and binary data

P: n/a
I'm storing gzipped data in a MySQL blob field. I can fetch the blob and
"wb" write the data to a file. It becomes a file containg gz data.

I can't take the same data and do anything sensible with it in python -
like say zlib.decompress(data).

How can I convert the binary data from the blob field to the gzipped
string it was stored as (java stores the string, Pickle is not an option)?

regards

/rune
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 10 Dec 2004 16:58:56 +0100
Rune Hansen <ru*********@scanmine.com> wrote:
I'm storing gzipped data in a MySQL blob field. I can fetch the blob and
"wb" write the data to a file. It becomes a file containg gz data.

I can't take the same data and do anything sensible with it in python -
like say zlib.decompress(data).

How can I convert the binary data from the blob field to the gzipped
string it was stored as (java stores the string, Pickle is not an option)?


You can pass any file-like object to GzipFile class:

from gzip import GzipFile
from cStringIO import StringIO
GzipFile(fileobj=StringIO(data)).read()

--
Denis S. Otkidach
http://www.python.ru/ [ru]
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.