nodes: 0, module; 1, function_definition; 2, function_name:query; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, if_statement; 17, expression_statement; 18, if_statement; 19, if_statement; 20, if_statement; 21, if_statement; 22, if_statement; 23, return_statement; 24, identifier:query; 25, string; 26, identifier:name; 27, string; 28, identifier:sortlist; 29, string; 30, identifier:columns; 31, string; 32, identifier:limit; 33, integer:0; 34, identifier:offset; 35, integer:0; 36, identifier:style; 37, string; 38, comment:"""Query the table and return the result as a reference table.
  
          This method queries the table. It forms a
          `TaQL <../../doc/199.html>`_
          command from the given arguments and executes it using the
          :func:`taql` function.
          The result is returned in a so-called reference table which
          references the selected columns and rows in the original table.
          Usually a reference table is temporary, but it can be made
          persistent by giving it a name.
          Note that a reference table is handled as any table, thus can be
          queried again.
  
          All arguments are optional, but at least one of `query`, `name`,
          `sortlist`, and `columns` should be used.
          See the `TaQL note <../../doc/199.html>`_ for the
          detailed description of the the arguments representing the various
          parts of a TaQL command.
  
          `query`
            The WHERE part of a TaQL command.
          `name`
            The name of the reference table if it is to be made persistent.
          `sortlist`
            The ORDERBY part of a TaQL command. It is a single string in which
            commas have to be used to separate sort keys.
          `columns`
            The columns to be selected (projection in data base terms). It is a
            single string in which commas have to be used to separate column
            names. Apart from column names, expressions can be given as well.
          `limit`
            If > 0, maximum number of rows to be selected.
          `offset`
            If > 0, ignore the first N matches.
          `style`
            The TaQL syntax style to be used (defaults to Python).
  
          """; 39, boolean_operator; 40, block; 41, assignment; 42, identifier:columns; 43, block; 44, augmented_assignment; 45, identifier:query; 46, block; 47, identifier:sortlist; 48, block; 49, comparison_operator:limit > 0; 50, block; 51, comparison_operator:offset > 0; 52, block; 53, identifier:name; 54, block; 55, call; 56, string_content:Python; 57, boolean_operator; 58, comparison_operator:offset <= 0; 59, raise_statement; 60, identifier:command; 61, string; 62, expression_statement; 63, identifier:command; 64, string; 65, expression_statement; 66, expression_statement; 67, identifier:limit; 68, integer:0; 69, expression_statement; 70, identifier:offset; 71, integer:0; 72, expression_statement; 73, expression_statement; 74, identifier:tablecommand; 75, argument_list; 76, boolean_operator; 77, line_continuation:\; 78, comparison_operator:limit <= 0; 79, identifier:offset; 80, integer:0; 81, call; 82, string_content:select; 83, augmented_assignment; 84, string_content:from $1; 85, augmented_assignment; 86, augmented_assignment; 87, augmented_assignment; 88, augmented_assignment; 89, augmented_assignment; 90, identifier:command; 91, identifier:style; 92, list; 93, boolean_operator; 94, not_operator; 95, identifier:limit; 96, integer:0; 97, identifier:ValueError; 98, argument_list; 99, identifier:command; 100, identifier:columns; 101, identifier:command; 102, binary_operator:' where ' + query; 103, identifier:command; 104, binary_operator:' orderby ' + sortlist; 105, identifier:command; 106, binary_operator:' limit %d' % limit; 107, identifier:command; 108, binary_operator:' offset %d' % offset; 109, identifier:command; 110, binary_operator:' giving ' + name; 111, identifier:self; 112, not_operator; 113, not_operator; 114, identifier:columns; 115, binary_operator:'No selection done (arguments query, ' +
                               'sortlist, columns, limit, and offset are empty)'; 116, string; 117, identifier:query; 118, string; 119, identifier:sortlist; 120, string; 121, identifier:limit; 122, string; 123, identifier:offset; 124, string; 125, identifier:name; 126, identifier:query; 127, identifier:sortlist; 128, string; 129, string; 130, string_content:where; 131, string_content:orderby; 132, string_content:limit %d; 133, string_content:offset %d; 134, string_content:giving; 135, string_content:No selection done (arguments query,; 136, string_content:sortlist, columns, limit, and offset are empty)
code: def query(self, query='', name='', sortlist='', columns='',
                limit=0, offset=0, style='Python'):
          """Query the table and return the result as a reference table.
  
          This method queries the table. It forms a
          `TaQL <../../doc/199.html>`_
          command from the given arguments and executes it using the
          :func:`taql` function.
          The result is returned in a so-called reference table which
          references the selected columns and rows in the original table.
          Usually a reference table is temporary, but it can be made
          persistent by giving it a name.
          Note that a reference table is handled as any table, thus can be
          queried again.
  
          All arguments are optional, but at least one of `query`, `name`,
          `sortlist`, and `columns` should be used.
          See the `TaQL note <../../doc/199.html>`_ for the
          detailed description of the the arguments representing the various
          parts of a TaQL command.
  
          `query`
            The WHERE part of a TaQL command.
          `name`
            The name of the reference table if it is to be made persistent.
          `sortlist`
            The ORDERBY part of a TaQL command. It is a single string in which
            commas have to be used to separate sort keys.
          `columns`
            The columns to be selected (projection in data base terms). It is a
            single string in which commas have to be used to separate column
            names. Apart from column names, expressions can be given as well.
          `limit`
            If > 0, maximum number of rows to be selected.
          `offset`
            If > 0, ignore the first N matches.
          `style`
            The TaQL syntax style to be used (defaults to Python).
  
          """
          if not query and not sortlist and not columns and \
             limit <= 0 and offset <= 0:
              raise ValueError('No selection done (arguments query, ' +
                               'sortlist, columns, limit, and offset are empty)')
          command = 'select '
          if columns:
              command += columns
          command += ' from $1'
          if query:
              command += ' where ' + query
          if sortlist:
              command += ' orderby ' + sortlist
          if limit > 0:
              command += ' limit %d' % limit
          if offset > 0:
              command += ' offset %d' % offset
          if name:
              command += ' giving ' + name
          return tablecommand(command, style, [self])