summaryrefslogtreecommitdiffstats
path: root/feed/sse_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'feed/sse_db.py')
-rw-r--r--feed/sse_db.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/feed/sse_db.py b/feed/sse_db.py
index 16b07c7..bd74f15 100644
--- a/feed/sse_db.py
+++ b/feed/sse_db.py
@@ -30,8 +30,9 @@ def find_package(md):
if cursor.rowcount <= 0:
return None
-
- return (int(cursor.fetchone()[0]), int(cursor.fetchone()[1]))
+
+ r = cursor.fetchone()
+ return (int(r[0]), int(r[1]))
def new_provider_record(recid, package_id, provider_id, meta):
@@ -63,12 +64,13 @@ def new_file(package_id, path, language_id = 0):
return (SSE_CRAWLER_ID, last_insert_id())
-def new_word(file_id, text, is_subword):
+def new_word(file_id, text, is_subword, n):
if is_subword:
- t = "subword"
+ wtype = "subword"
else:
- t = "word"
+ wtype = "word"
+
+ assert n > 0
- cursor.execute('INSERT IGNORE INTO word (text, type, crawler_id, file_id, cnt) VALUES (%s, %s, %s, %s, 0)', (text, t, file_id[0], file_id[1]))
- cursor.execute('UPDATE word SET cnt=cnt+1 WHERE text=%s AND type=%s AND crawler_id=%s AND file_id=%s', (text, t, file_id[0], file_id[1]))
+ cursor.execute('INSERT INTO word (text, type, crawler_id, file_id, cnt) VALUES (%s, %s, %s, %s, %s)', (text, wtype, file_id[0], file_id[1], n))