def GetNumberOfRows(self, table_name):
    """Retrieves the number of rows in the table.

    Args:
      table_name (str): name of the table.

    Returns:
      int: number of rows.

    Raises:
      IOError: if the file-like object has not been opened.
      OSError: if the file-like object has not been opened.
    """
    if not self._connection:
      raise IOError('Not opened.')

    self._cursor.execute(self._NUMBER_OF_ROWS_QUERY.format(table_name))
    row = self._cursor.fetchone()
    if not row:
      raise IOError(
          'Unable to retrieve number of rows of table: {0:s}'.format(
              table_name))

    number_of_rows = row[0]
    if isinstance(number_of_rows, py2to3.STRING_TYPES):
      try:
        number_of_rows = int(number_of_rows, 10)
      except ValueError as exception:
        raise IOError((
            'Unable to determine number of rows of table: {0:s} '
            'with error: {1!s}').format(table_name, exception))

    return number_of_rows
Retrieves the number of rows in the table.

    Args:
      table_name (str): name of the table.

    Returns:
      int: number of rows.

    Raises:
      IOError: if the file-like object has not been opened.
      OSError: if the file-like object has not been opened.