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))))

你可能感兴趣的:(sqlite3)