| @@ -123,12 +123,12 @@ def _get_cached_results(page, conn, mode): | |||||
| with conn.cursor() as cursor: | with conn.cursor() as cursor: | ||||
| cursor.execute(query1) | cursor.execute(query1) | ||||
| cursor.execute(query2, (cache_id,)) | |||||
| cursor.execute(query2, (buffer(cache_id),)) | |||||
| results = cursor.fetchall() | results = cursor.fetchall() | ||||
| if not results: | if not results: | ||||
| return None | return None | ||||
| cache_time, queries, check_time = results[0] | cache_time, queries, check_time = results[0] | ||||
| cursor.execute(query3, (cache_id,)) | |||||
| cursor.execute(query3, (buffer(cache_id),)) | |||||
| data = cursor.fetchall() | data = cursor.fetchall() | ||||
| if not data: # TODO: do something less hacky for this edge case | if not data: # TODO: do something less hacky for this edge case | ||||
| @@ -171,11 +171,11 @@ def _cache_result(page, result, conn, mode): | |||||
| query2 = "INSERT INTO cache VALUES (?, DEFAULT, ?, ?)" | query2 = "INSERT INTO cache VALUES (?, DEFAULT, ?, ?)" | ||||
| query3 = "INSERT INTO cache_data VALUES (DEFAULT, ?, ?, ?, ?)" | query3 = "INSERT INTO cache_data VALUES (DEFAULT, ?, ?, ?, ?)" | ||||
| cache_id = sha256(mode + page.get().encode("utf8")).digest() | cache_id = sha256(mode + page.get().encode("utf8")).digest() | ||||
| data = [(cache_id, source.url, source.confidence, source.skipped) | |||||
| data = [(buffer(cache_id), source.url, source.confidence, source.skipped) | |||||
| for source in result.sources] | for source in result.sources] | ||||
| with conn.cursor() as cursor: | with conn.cursor() as cursor: | ||||
| cursor.execute("START TRANSACTION") | cursor.execute("START TRANSACTION") | ||||
| cursor.execute(query1, (cache_id,)) | |||||
| cursor.execute(query2, (cache_id, result.queries, result.time)) | |||||
| cursor.execute(query1, (buffer(cache_id),)) | |||||
| cursor.execute(query2, (buffer(cache_id), result.queries, result.time)) | |||||
| cursor.executemany(query3, data) | cursor.executemany(query3, data) | ||||
| cursor.execute("COMMIT") | cursor.execute("COMMIT") | ||||