You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
950 B
24 lines
950 B
import sqlite3
|
|
import os
|
|
osp = os.path
|
|
DB_PATH = osp.join(osp.dirname(__file__),'ext.db')
|
|
ext_database = sqlite3.connect(DB_PATH)
|
|
def init_table():
|
|
cur = ext_database.cursor()
|
|
cur.execute('CREATE TABLE "update_times" ( `ext` TEXT, `update_times` INTEGER, PRIMARY KEY(`ext`) )')
|
|
class Searcher:
|
|
def __init__(self,ext):
|
|
self.cur = ext_database.cursor()
|
|
self.ext = ext
|
|
self.index = '{}_index'.format(ext)
|
|
self.__init_table__()
|
|
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):
|
|
# update logic
|
|
self.cur.executemany('INSERT OR IGNORE INTO ? VALUES (?,?)',params)
|
|
def _commit_(self):
|
|
ext_database.commit()
|
|
def search(query,regex=False):
|
|
pass
|