(self, key)
return table
Indexing of SqlTable is performed in the following way:

        If a single row is requested, it is fetched from the database and
        returned as a SqlRowInstance.

        A new SqlTable with appropriate filters is constructed and returned
        otherwise.
Indexing of SqlTable is performed in the following way:
Indexing of SqlTable is performed in the following way :
def __getitem__(self, key):
        """ Indexing of SqlTable is performed in the following way:

        If a single row is requested, it is fetched from the database and
        returned as a SqlRowInstance.

        A new SqlTable with appropriate filters is constructed and returned
        otherwise.
        """
        if isinstance(key, int):
            # one row
            return self._fetch_row(key)

        if not isinstance(key, tuple):
            # row filter
            key = (key, Ellipsis)

        if len(key) != 2:
            raise IndexError("Table indices must be one- or two-dimensional")

        row_idx, col_idx = key
        if isinstance(row_idx, int):
            try:
                col_idx = self.domain.index(col_idx)
                var = self.domain[col_idx]
                return Value(
                    var,
                    next(self._query([var], rows=[row_idx]))[0]
                )
            except TypeError:
                pass

        elif not (row_idx is Ellipsis or row_idx == slice(None)):
            # TODO if row_idx specify multiple rows, one of the following must
            # happen
            #  - the new table remembers which rows are selected (implement
            #     table.limit_rows and whatever else is necessary)
            #  - return an ordinary (non-SQL) Table
            #  - raise an exception
            raise NotImplementedError("Row indices must be integers.")

        # multiple rows OR single row but multiple columns:
        # construct a new table
        table = self.copy()
        table.domain = self.domain.select_columns(col_idx)
        # table.limit_rows(row_idx)
        return table
def __getitem__ ( self , key ) : if isinstance ( key , int ) : # one row return self . _fetch_row ( key ) if not isinstance ( key , tuple ) : # row filter key = ( key , Ellipsis ) if len ( key ) != 2 : raise IndexError ( "Table indices must be one- or two-dimensional" ) row_idx , col_idx = key if isinstance ( row_idx , int ) : try : col_idx = self . domain . index ( col_idx ) var = self . domain [ col_idx ] return Value ( var , next ( self . _query ( [ var ] , rows = [ row_idx ] ) ) [ 0 ] ) except TypeError : pass elif not ( row_idx is Ellipsis or row_idx == slice ( None ) ) : # TODO if row_idx specify multiple rows, one of the following must # happen #  - the new table remembers which rows are selected (implement #     table.limit_rows and whatever else is necessary) #  - return an ordinary (non-SQL) Table #  - raise an exception raise NotImplementedError ( "Row indices must be integers." ) # multiple rows OR single row but multiple columns: # construct a new table table = self . copy ( ) table . domain = self . domain . select_columns ( col_idx ) # table.limit_rows(row_idx) return table