From de19d825770f1377700366686e217b957c70f78c Mon Sep 17 00:00:00 2001 From: rlbr Date: Fri, 26 Oct 2018 16:25:07 -0500 Subject: [PATCH] Put down sql queries renamed init_tables to init_db --- searcher.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/searcher.py b/searcher.py index 5dddaba..a1a966a 100644 --- a/searcher.py +++ b/searcher.py @@ -3,9 +3,9 @@ import os osp = os.path DB_PATH = osp.join(osp.dirname(__file__),'ext.db') ext_database = sqlite3.connect(DB_PATH) -def init_table(): +def init_db(): cur = ext_database.cursor() - cur.execute('CREATE TABLE "update_times" ( `ext` TEXT, `update_times` INTEGER, PRIMARY KEY(`ext`) )') + cur.execute('CREATE TABLE "updates" ( `ext` TEXT, `update_time` INTEGER, `file_count` INTEGER, PRIMARY KEY(`ext`) )') class Searcher: def __init__(self,ext): self.cur = ext_database.cursor() @@ -14,9 +14,10 @@ class Searcher: def __init_table__(self): self.cur.execute('CREATE TABLE IF NOT EXISTS ? (`name` TEXT,`fullpath` TEXT,UNIQUE(name,fullpath));',[self.ext]) self.cur.execute('CREATE INDEX IF NOT EXISTS ? ON ? ( `name`, `fullpath` )',[self.index,self.ext]) - def _update_(self): + def _update_(self,update_mtimes): # update logic self.cur.executemany('INSERT OR IGNORE INTO ? VALUES (?,?)',params) + self.cur.execute('INSERT INTO updates VALUES (?, ?, ?)',[self.ext,time,count]) def _commit_(self): ext_database.commit() def search(query,regex=False):