crawler: fix sqlite/binary issue

master
pictuga 2017-11-25 19:58:14 +01:00
parent 21480f90de
commit f9217102f3
1 changed files with 4 additions and 0 deletions

View File

@ -494,6 +494,10 @@ class SQLiteCache(BaseCache):
return row[1:] return row[1:]
def __setitem__(self, url, value): # value = (code, msg, headers, data, timestamp) def __setitem__(self, url, value): # value = (code, msg, headers, data, timestamp)
value = list(value)
value[3] = sqlite3.Binary(value[3]) # data
value = tuple(value)
if url in self: if url in self:
with self.con: with self.con:
self.con.execute('UPDATE data SET code=?, msg=?, headers=?, data=?, timestamp=? WHERE url=?', self.con.execute('UPDATE data SET code=?, msg=?, headers=?, data=?, timestamp=? WHERE url=?',