我正在使用 Python 2.6 从 SQL Server 读取数据。我被卡住了,因为我的数据库中的一列是 varbinary。我用的是pyodbc,Python程序中的数据类型是“buffer”。
现在,数据库中的此列存储 gzip 压缩文本。如果可以访问“缓冲区”数据类型,我无法弄清楚如何从 Python 中解压缩它。
请问有什么帮助/指点吗?
这就是我正在做的
con = pyodbc.connect(...)
cursor = con.cursor()
cursor.execute('select ...')
row = cursor.fetchone()
if row:
x = row.varbinary_column_name
asciistring = zlib.decompress(x) # throws zlib.error: Error -3 while
# decompressing data: incorrect header check
提前致谢!