MySql:如何知道条目是否被压缩

时间:2010-04-04 14:22:35

标签: python mysql

我正在使用python和mysql,我想验证数据库中是否压缩了某个条目。即:

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

此时我想验证条目是否已压缩(即为了工作包含您必须使用的数据select uncompress(compressed_column)..)。想法?

1 个答案:

答案 0 :(得分:4)

MySQL上的

COMPRESS()使用zlib,因此你可以尝试以下方法来查看字符串是否被压缩:

try:
  out = s.decode('zlib')
except zlib.error:
  out = s
相关问题