def refreshDatabase(self, notepad): self.l.debug('Refreshing database {}'.format(self.dbFile)) self.conn.execute(''' DELETE FROM pageref''') self.conn.execute(''' DELETE FROM page''') # TODO: We need a Notepad instance here. # Then the following code to search through a notepad can be moved into the Notepad class: for root, dirnames, filenames in os.walk(self.rootDir): for filename in fnmatch.filter(filenames, '*.xml'): pageId = urllib.parse.unquote(filename)[:-4] stmt = ''' INSERT INTO page VALUES(?)''' self.conn.execute(stmt, (pageId, ) ) page = LocalPage(notepad, pageId) page.load() # print('\n"{}"'.format(pageId)) for childLink in page.getLinks(): # print(' => "{}"'.format(childLink)) stmt = ''' INSERT INTO pageref VALUES(?, ?)''' self.conn.execute(stmt, (pageId, childLink)) # print() self.conn.commit()