class_docstr: Build a SQLite database from folder with txt files, json files or
  `Wiki Extractor <https://github.com/attardi/wikiextractor>`_ files.
class_docstr_tok: ["Build","a","SQLite","database","from","folder","with","txt","files",",","json","files","or","`","Wiki","Extractor","<","https",":","\/\/github.com\/attardi\/wikiextractor",">","`","_","files","."]
docstr: 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
docstr_tok: ["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","`","does","n't","exist",".","RuntimeError","if","dataset_format","is","not","in","[","'txt","'",",","'json","'",",","'wiki","'","]","Returns",":","None"]
code: 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()
  
imports: import json
  import logging
  import sqlite3
  import unicodedata
  from multiprocessing import Pool
  from pathlib import Path
  from typing import Union, List, Tuple, Generator, Any, Optional
  from tqdm import tqdm
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.dataset_reader import DatasetReader
  from deeppavlov.core.data.utils import download
label_desc: Use image node_id 3 for calling the ODQADataReader obj's underlying member method code with example usage: obj._build_db(save_path, dataset_format, data_path, num_workers) without return types