class_docstr: Class implementing database connection.
  
  Example
  -------
  >>> AMPLIGRAPH_DATA_HOME='/your/path/to/datasets/'
  >>> # Initialize GraphDataLoader from .csv file
  >>> data = GraphDataLoader("data.csv", backend=SQLiteAdapter)
  >>> # Initialize GraphDataLoader from .txt file using indexer
  >>> # to map entities to integers
  >>> data = GraphDataLoader(AMPLIGRAPH_DATA_HOME + "fb15k/test.txt",
  >>>                        backend=SQLiteAdapter("database.db",
  >>>                        use_indexer=True))
  >>> for elem in data:
  >>>     print(elem)
  >>>     break
  [(1, 1, 2)]
  >>> # Populate the database with raw triples for training
  >>> with SQLiteAdapter("database.db") as backend:
  >>>     backend.populate(AMPLIGRAPH_DATA_HOME + "fb15k/train.txt",
  >>>                      dataset_type="train")
  >>> # Populate the database with indexed triples for training
  >>> with SQLiteAdapter("database.db", use_indexer=True) as backend:
  >>>     backend.populate(AMPLIGRAPH_DATA_HOME + "fb15k/train.txt",
  >>>                      dataset_type="train")
docstr: Generator that returns the next batch of data.
  
  Parameters
  ----------
  dataset_type: str
      Indicates which dataset to use
      (`"train"` | `"test"` | `"validation"`).
  batch_size: int
      Number of elements in a batch (default: :math:`1`).
  index_by: str
      Possible values:  `{"", "so", "os", "s", "o"}`. It indicates
      whether to use index and which to use:
      index by subject (`"s"`), object (`"o"`) or both (`"so"`, `"os"`).
      Indexes were created for the fields so SQLite should use them
      here to speed up, see example below:
     sqlite> EXPLAIN QUERY PLAN SELECT * FROM triples_table                   ORDER BY subject, object LIMIT 7000, 30;
     QUERY PLAN
     `--SCAN TABLE triples_table USING INDEX triples_table_sub_obj_idx
  random: bool
      Whether to get records from database in a random order.
  
  Yields
  -------
  batch_output : ndarray
      Yields a batch of triples from the dataset type specified
  participating_entities : list
      List of all entities that were involved in the s-p-? and
      ?-p-o relations. This is returned only if ``use_filter=True``.
docstr_tok: ["Generator","that","returns","the","next","batch","of","data",".","Parameters","--","--","--","--","--","dataset_type",":","str","Indicates","which","dataset","to","use","(","`","``","train","''","`","|","`","``","test","''","`","|","`","``","validation","''","`",")",".","batch_size",":","int","Number","of","elements","in","a","batch","(","default",":",":","math",":","`","1","`",")",".","index_by",":","str","Possible","values",":","`","{","``","''",",","``","so","''",",","``","os","''",",","``","s","''",",","``","o","''","}","`",".","It","indicates","whether","to","use","index","and","which","to","use",":","index","by","subject","(","`","``","s","''","`",")",",","object","(","`","``","o","''","`",")","or","both","(","`","``","so","''","`",",","`","``","os","''","`",")",".","Indexes","were","created","for","the","fields","so","SQLite","should","use","them","here","to","speed","up",",","see","example","below",":","sqlite",">","EXPLAIN","QUERY","PLAN","SELECT","*","FROM","triples_table","ORDER","BY","subject",",","object","LIMIT","7000",",","30",";","QUERY","PLAN","`","--","SCAN","TABLE","triples_table","USING","INDEX","triples_table_sub_obj_idx","random",":","bool","Whether","to","get","records","from","database","in","a","random","order",".","Yields","--","--","--","-","batch_output",":","ndarray","Yields","a","batch","of","triples","from","the","dataset","type","specified","participating_entities",":","list","List","of","all","entities","that","were","involved","in","the","s-p-","?","and","?","-p-o","relations",".","This","is","returned","only","if","``","use_filter=True","``","."]
code: def _get_batch_generator(
      self,
      batch_size=1,
      dataset_type="train",
      random=False,
      index_by="",
  ):
      """Generator that returns the next batch of data.
  
          Parameters
          ----------
          dataset_type: str
              Indicates which dataset to use
              (`"train"` | `"test"` | `"validation"`).
          batch_size: int
              Number of elements in a batch (default: :math:`1`).
          index_by: str
              Possible values:  `{"", "so", "os", "s", "o"}`. It indicates
              whether to use index and which to use:
              index by subject (`"s"`), object (`"o"`) or both (`"so"`, `"os"`).
              Indexes were created for the fields so SQLite should use them
              here to speed up, see example below:
             sqlite> EXPLAIN QUERY PLAN SELECT * FROM triples_table\
                     ORDER BY subject, object LIMIT 7000, 30;
             QUERY PLAN
             `--SCAN TABLE triples_table USING INDEX triples_table_sub_obj_idx
          random: bool
              Whether to get records from database in a random order.
  
          Yields
          -------
          batch_output : ndarray
              Yields a batch of triples from the dataset type specified
          participating_entities : list
              List of all entities that were involved in the s-p-? and
              ?-p-o relations. This is returned only if ``use_filter=True``.
  
          """
      if not isinstance(dataset_type, str):
          dataset_type = dataset_type.decode("utf-8")
      cond = f"where dataset_type ='{dataset_type}'"
      size = self.get_data_size(condition=cond)
      # focusE: size ppi55k = 230929
      self.batches_count = int(np.ceil(size / batch_size))
      logger.debug("batches count: {}".format(self.batches_count))
      logger.debug("size of data: {}".format(size))
      index = ""
      if index_by != "":
          if (
              index_by == "s"
              or index_by == "o"
              or index_by == "so"
              or index_by == "os"
          ) and random:
              msg = "Field index_by can only be used with random set\
                          to False and can only take values from this\
                          set: {{s,o,so,os,''}},\
                          instead got: {}".format(
                  index_by
              )
              logger.error(msg)
              raise Exception(msg)
  
          if index_by == "s":
              index = "ORDER BY subject"
          if index_by == "o":
              index = "ORDER BY object"
          if index_by == "so" or index_by == "os":
              index = "ORDER BY subject, object"
          if index == "" and random:
              index = "ORDER BY random()"
      query_template = "SELECT * FROM triples_table INDEXED BY \
                   triples_table_type_idx where\
                   dataset_type ='{}' {} LIMIT {}, {};"
  
      for i in range(self.batches_count):
          # logger.debug("BATCH NUMBER: {}".format(i))
          # logger.debug(i * batch_size)
          query = query_template.format(
              dataset_type, index, i * batch_size, batch_size
          )
          # logger.debug(query)
          out = self._execute_query(query)
          # logger.debug(out)
          if out:
              triples = np.array(out)[:, :3].astype(np.int32)
              # focusE
              if self.data_shape > 3:
                  weights = np.array(out)[:, 3:-1]
  
          else:
              weights = np.array([])
  
          if self.use_filter:
              # get the filter values
              participating_entities = self._get_complementary_entities(
                  triples
              )
              if self.data_shape > 3:
                  yield triples, tf.ragged.constant(
                      participating_entities
                  ),
                  weights
              else:
                  yield triples, tf.ragged.constant(
                      participating_entities
                  )
          else:
              if self.data_shape > 3:
                  yield triples, weights
              else:
                  yield triples
  
imports: import logging
  import os
  import sqlite3
  import tempfile
  from sqlite3 import Error
  from urllib.request import pathname2url
  import numpy
  import pandas
  import tensorflow
  from ampligraph.utils.profiling import get_human_readable_size
  from .data_indexer import DataIndexer
label_desc: Use image node_id 26 for calling the SQLiteAdapter obj's underlying member method code with example usage: obj._get_batch_generator(batch_size, dataset_type, random, index_by) without return types