It's not clear to me what you mean by "the first line" (gzip does not
output a file composed of lines, its output is byte-oriented).

Printing tst.getvalue() is probably not a very useful thing to do, since
it won't do anything useful when the output is a terminal, and it will
add an extra newline if you are redirecting to a file.

At least when close()ing the GzipFile before looking at the StringIO
instance's value, I get some bytes that gunzip just fine, giving the
original string.

Here's my interactive session:
>>> import gzip
>>> import StringIO
>>> io = StringIO.StringIO()
>>> z = gzip.GzipFile("test.gz", "w", 5, io)
>>> z.write("""\
... Python 2.2.2 (#1, Feb 24 2003, 19:13:11) 
... [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
... Type "help", "copyright", "credits" or "license" for more information.
... """)
>>> z.close()
>>> from os import popen
>>> popen("gunzip -dc", "w").write(io.getvalue())
Python 2.2.2 (#1, Feb 24 2003, 19:13:11) 
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

I don't know anything about your database or its "LONG field".
Depending on the database software there could be additional problems
with embedded NULs, for instance.

Jeff

Attachment: pgpRFzYLb7Oet.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to