python error:sqlite3

sqlite3.ProgrammingError:You must notuse8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str).Itis highly recommended that you instead just switch your application to Unicode strings

Found the solution, I should have spent just a little more time searching.

Solution is to 'cast' the value as a Python 'buffer', like so:

c.execute('insert or ignore into blah values (?, ?)',(cid, buffer(zlib.compress(html))))

posted @ 2011-11-21 22:47  王帅901  阅读(342)  评论(0编辑  收藏  举报