def __init__(self, handle, progressbar=None): ChessFile.__init__(self, handle) self.handle = handle self.progressbar = progressbar self.pgn_is_string = isinstance(handle, StringIO) if self.pgn_is_string: self.games = [ self.load_game_tags(), ] else: self.skip = 0 self.limit = 100 self.order_col = game.c.offset self.is_desc = False self.reset_last_seen() # filter expressions to .sqlite .bin .scout self.tag_query = None self.fen = None self.scout_query = None self.scoutfish = None self.chess_db = None self.sqlite_path = os.path.splitext(self.path)[0] + '.sqlite' self.engine = dbmodel.get_engine(self.sqlite_path) self.tag_database = TagDatabase(self.engine) self.games, self.offs_ply = self.get_records(0) log.info("%s contains %s game(s)" % (self.path, self.count), extra={"task": "SQL"})
def init_tag_database(self): sqlite_path = os.path.splitext(self.path)[0] + '.sqlite' self.engine = dbmodel.get_engine(sqlite_path) self.tag_database = TagDatabase(self.engine) # Import .pgn header tags to .sqlite database size = self.size if size > 0 and self.tag_database.count == 0: if size > 10000000: drop_indexes(self.engine) importer = PgnImport(self) importer.do_import(self.path, progressbar=self.progressbar) if size > 10000000: create_indexes(self.engine)