468,242 Members | 1,424 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

MySQLdb blob and binary data

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
1 5619
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.

Similar topics

3 posts views Thread by David Stockwell | last post: by
reply views Thread by Mark Fisher | last post: by
2 posts views Thread by Niraj | last post: by
11 posts views Thread by CSN | last post: by
reply views Thread by Wescotte | last post: by
1 post views Thread by Grzegorz Smith | last post: by
2 posts views Thread by gert | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.