From 7cd9a5320993b63c420ecc9433d449cda3bbcc0a Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 4 Sep 2014 23:12:11 -0500 Subject: [PATCH] Fix oursql coercing binary data to unicode. --- copyvios/checker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/copyvios/checker.py b/copyvios/checker.py index 91452d9..5940b65 100644 --- a/copyvios/checker.py +++ b/copyvios/checker.py @@ -123,12 +123,12 @@ def _get_cached_results(page, conn, mode): with conn.cursor() as cursor: cursor.execute(query1) - cursor.execute(query2, (cache_id,)) + cursor.execute(query2, (buffer(cache_id),)) results = cursor.fetchall() if not results: return None cache_time, queries, check_time = results[0] - cursor.execute(query3, (cache_id,)) + cursor.execute(query3, (buffer(cache_id),)) data = cursor.fetchall() 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, ?, ?)" query3 = "INSERT INTO cache_data VALUES (DEFAULT, ?, ?, ?, ?)" 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] with conn.cursor() as cursor: 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.execute("COMMIT")