Browse Source

Fix oursql coercing binary data to unicode.

pull/24/head
Ben Kurtovic 9 years ago
parent
commit
7cd9a53209
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      copyvios/checker.py

+ 5
- 5
copyvios/checker.py View File

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

Loading…
Cancel
Save