def _build_db(self, save_path: Union[Path, str], dataset_format: str,
                  data_path: Union[Path, str],
                  num_workers: int = 8) -> None:
        """Build a SQLite database in parallel and save it to a pointed path.

        Args:
            save_path: a path where the ready database should be saved
            dataset_format: a data format, should be selected from ['txt', 'json', 'wiki']
            data_path: path to a folder/file from which to build a database
            num_workers: a number of workers for parallel database building

        Raises:
            sqlite3.OperationalError if `save_path` doesn't exist.
            RuntimeError if dataset_format is not in ['txt', 'json', 'wiki']

        Returns:
            None

        """
        done_path = save_path.with_suffix(f'{save_path.suffix}.done')

        if Path(save_path).exists():
            Path(save_path).unlink()
        if done_path.exists():
            done_path.unlink()

        logger.info('Building the database...')

        try:
            conn = sqlite3.connect(str(save_path))
        except sqlite3.OperationalError as e:
            e.args = e.args + ("Check that DB path exists.",)
            raise e
        c = conn.cursor()
        sql_table = "CREATE TABLE documents (id PRIMARY KEY, text);"
        c.execute(sql_table)

        files = [f for f in self.iter_files(data_path)]
        workers = Pool(num_workers)

        if dataset_format == 'txt':
            fn = self._get_file_contents
        elif dataset_format == 'json':
            fn = self._get_json_contents
        elif dataset_format == 'wiki':
            fn = self._get_wiki_contents
        else:
            raise RuntimeError('Unknown dataset format.')

        with tqdm(total=len(files)) as pbar:
            for data in tqdm(workers.imap_unordered(fn, files)):
                try:
                    c.executemany("INSERT INTO documents VALUES (?,?)", data)
                    pbar.update()
                except sqlite3.IntegrityError as e:
                    logger.warning(e)

        conn.commit()
        conn.close()
        done_path.touch()
Build a SQLite database in parallel and save it to a pointed path.

        Args:
            save_path: a path where the ready database should be saved
            dataset_format: a data format, should be selected from ['txt', 'json', 'wiki']
            data_path: path to a folder/file from which to build a database
            num_workers: a number of workers for parallel database building

        Raises:
            sqlite3.OperationalError if `save_path` doesn't exist.
            RuntimeError if dataset_format is not in ['txt', 'json', 'wiki']

        Returns:
            None

        
deeppavlov/dataset_readers/odqa_reader.py