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.

23 lines
950 B

  1. import sqlite3
  2. import os
  3. osp = os.path
  4. DB_PATH = osp.join(osp.dirname(__file__),'ext.db')
  5. ext_database = sqlite3.connect(DB_PATH)
  6. def init_table():
  7. cur = ext_database.cursor()
  8. cur.execute('CREATE TABLE "update_times" ( `ext` TEXT, `update_times` INTEGER, PRIMARY KEY(`ext`) )')
  9. class Searcher:
  10. def __init__(self,ext):
  11. self.cur = ext_database.cursor()
  12. self.ext = ext
  13. self.index = '{}_index'.format(ext)
  14. self.__init_table__()
  15. def __init_table__(self):
  16. self.cur.execute('CREATE TABLE IF NOT EXISTS ? (`name` TEXT,`fullpath` TEXT,UNIQUE(name,fullpath));',[self.ext])
  17. self.cur.execute('CREATE INDEX IF NOT EXISTS ? ON ? ( `name`, `fullpath` )',[self.index,self.ext])
  18. def _update_(self):
  19. # update logic
  20. self.cur.executemany('INSERT OR IGNORE INTO ? VALUES (?,?)',params)
  21. def _commit_(self):
  22. ext_database.commit()
  23. def search(query,regex=False):
  24. pass