Browse Source

Fix default value; fix buffering for oursql.

pull/15/head
Ben Kurtovic 9 years ago
parent
commit
2c197b5378
2 changed files with 5 additions and 4 deletions
  1. +4
    -3
      tasks/afc_copyvios.py
  2. +1
    -1
      tasks/schema/afc_copyvios.sql

+ 4
- 3
tasks/afc_copyvios.py View File

@@ -207,11 +207,12 @@ class AFCCopyvios(Task):
query2 = "INSERT INTO cache VALUES (?, DEFAULT, ?, ?)"
query3 = "INSERT INTO cache_data VALUES (DEFAULT, ?, ?, ?, ?)"
cache_id = sha256("1:1:" + page.get().encode("utf8")).digest()
data = [(cache_id, source.url, source.confidence, source.skipped)
buff = buffer(cache_id)
data = [(buff, source.url, source.confidence, source.skipped)
for source in result.sources]
with self.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, (buff,))
cursor.execute(query2, (buff, result.queries, result.time))
cursor.executemany(query3, data)
cursor.execute("COMMIT")

+ 1
- 1
tasks/schema/afc_copyvios.sql View File

@@ -31,7 +31,7 @@ CREATE TABLE `cache_data` (
`cdata_cache_id` BINARY(32) NOT NULL,
`cdata_url` VARCHAR(512) NOT NULL,
`cdata_confidence` FLOAT NOT NULL DEFAULT 0,
`cdata_skipped` BOOLEAN NOT NULL DEFAULT "false",
`cdata_skipped` BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY (`cdata_id`),
FOREIGN KEY (`cdata_cache_id`)
REFERENCES `cache` (`cache_id`)


Loading…
Cancel
Save