tags:

views:

34

answers:

1

I'm working with python and mysql and I want to verify that a certain entry is compressed in the db. Ie:

cur = db.getCursor()
cur.execute('''select compressed_column from table where id=12345''')
res = cur.fetchall()

at this point I would like to verify that the entry is compressed (ie in order to work with the data you would have to use select uncompress(compressed_column)..). Ideas?

+3  A: 

COMPRESS() on MySQL uses zlib, therefore you can try the following to see if the string is compressed:

try:
  out = s.decode('zlib')
except zlib.error:
  out = s
Ignacio Vazquez-Abrams