Performs query operations (Read) against the server.
 Typically this returns an array of record instances, except in the case of count queries
 @raise [ServiceError] if there is an error when talking to the service
5880
def execute
    begin
      @response = OData::Resource.new(build_query_uri, @rest_options).get
    rescue Exception => e
      handle_exception(e)
    end
    return Integer(@response.body) if @response.body =~ /\A\d+\z/
    handle_collection_result(@response.body)
  end
20611
function QueryDBRead(params) {
        RED.nodes.createNode(this, params);
        this.name = params.name;
        this.waitfor = params.waitfor;
        let node = this;
        this.on('input', function(msg) {
            if (msg.error) {
                // FIXME: Add error handling here
            } else {
                params.actionType = 'read';
                node.log('QueryDBNode');
                node.log(JSON.stringify(params));
                // node.log(JSON.stringify(msg));
                processDBNode(node, params, msg);
            }
        });
    }
1361218
def query_facts(query, facts = [])
      fields = Hash[facts.collect { |fact| [fact.to_sym, 1] }]
      collection = connection[nodes_collection]
      result = {}
      collection.find(query).batch_size(999).projection(fields).each do |values|
        id = values.delete('_id')
        result[id] = values
      end
      result
    end
995942
def [](url)
      interpret case
        when store.respond_to?(:[])
          store[key_for(url)]
        when store.respond_to?(:get)
          store.get key_for(url)
        when store.respond_to?(:read)
          store.read key_for(url)
      end
    end
783351
def readACTIONRECORDs(self):
        
        out = []
        while 1:
            action = self.readACTIONRECORD()
            if action:
                out.append(action)
            else:
                break
        return out
574096
def __read_single_query_result(rs, field_names):
    '''
    
    '''

    rf = StringIO.StringIO(rs)

    def readline():
        l = rf.readline()
        if not l.endswith('\n'):
            raise EOFError()
        return l.strip()

    result = Result()

    try:
        l = readline()
        assert l.startswith('# BLAST')

        l = readline()
        assert l.startswith('# Query: ')
        query_str = l[len('# Query: '):].strip()
        if query_str:
            if ' ' in query_str:
                result.id, result.description = [
                    s.strip() for s in query_str.split(' ', 1)]
            else:
                result.id = query_str

        l = readline()
        assert l.startswith('# Database: ')

        l = readline()
        if l.startswith('# Fields: '):
            fns = l[len('# Fields: '):].split(', ')
            assert len(field_names) == len(fns)
            l = readline()

        assert l.endswith(' hits found')
        nhits = int(l[len('# '):-1 * len(' hits found')])

        while nhits > 0:
            l = readline()
            field_vals = l.split('\t')
            assert len(field_vals) == len(field_names)

            fields = dict(zip(field_names, field_vals))
            result.hits.append(Hit(fields))
            nhits -= 1

        return result, rf.read()
    except EOFError:
        return None, rs
582304
def results
      return @results if defined? @results
      return [] if frozen?

      enforce_timezone do
        case query
        when /\ADELETE/i
          @affected_rows = connection.delete(query, "#{self.class.name} Delete")

        when /\AINSERT/i
          @last_insert_id = connection.insert(query, "#{self.class.name} Insert")

        when /\AUPDATE/i
          @affected_rows = connection.update(query, "#{self.class.name} Update")

        when /\ASELECT/i
          # Why not execute or select_rows? Because select_all hits the query cache.
          ar_results = connection.select_all(query, "#{self.class.name} Select")
          @hash_results = ar_results.to_ary
          @results = ar_results.rows
        else
          @results = connection.execute(query, "#{self.class.name} Execute").to_a
        end

        @results ||= []

        retrieve_found_row_count
        freeze

        @results
      end
    end
1175147
def records(self):
		''''''
		if self._records == None:
			self._records = self._get_records()
		return self._records
1311126
def fetch(query, max_rows = 100)
      # Execute the query and check the result
      exec_result = execute(query)
      raise_error_if_failed!(exec_result)

      # Get search operation handle to fetch the results
      op_handle = exec_result.operationHandle
      
      # Fetch the rows
      fetch_rows(op_handle, :first, max_rows)
    end
870283
def get_records(self):
        
        # Won't be able to find new records.
        if self.exhausted:
            return []

        # Already caught up, just the one call please.
        if self.empty_responses >= CALLS_TO_REACH_HEAD:
            return self._apply_get_records_response(self.session.get_stream_records(self.iterator_id))

        # Up to 5 calls to try and find a result
        while self.empty_responses < CALLS_TO_REACH_HEAD and not self.exhausted:
            records = self._apply_get_records_response(self.session.get_stream_records(self.iterator_id))
            if records:
                return records

        return []
755404
def _list_records(self, rtype=None, name=None, content=None):
        """"""
        if self.protocol == 'rpc':
            return self.rpc_helper.list_records(rtype, name, content)

        try:
            if name is not None:
                if rtype is not None:
                    query_results = [self._get(
                        '/domains/{0}/records/{1}/{2}'
                        .format(self.domain_id, self._relative_name(name), rtype))]
                else:
                    query_results = self._get('/domains/{0}/records/{1}'
                                              .format(self.domain_id, self._relative_name(name)))
            else:
                query_results = self._get(
                    '/domains/{0}/records'.format(self.domain_id))
                if rtype is not None:
                    query_results = [
                        item for item in query_results if item['rrset_type'] == rtype]
        except requests.exceptions.HTTPError as error:
            if error.response.status_code == 404:
                query_results = []
            else:
                raise

        # convert records with multiple values into single-value records
        records = []
        for query_result in query_results:
            for value in query_result['rrset_values']:
                record = {
                    'type': query_result['rrset_type'],
                    'name': self._full_name(query_result['rrset_name']),
                    'ttl': query_result['rrset_ttl'],
                    'content': value,
                    'id': query_result['rrset_name'],
                }
                # cleanup potential quoting if suitable
                self._clean_TXT_record(record)
                records.append(record)
        # filter for content, if requested
        if content is not None:
            records = [
                record for record in records if record['content'] == content]
        LOGGER.debug('list_records: %s', records)
        return records
295955
def queryMany(self, query, args):
		
		self.lastError = None
		self.affectedRows = None
		self.rowcount = None
		self.record = None
		cursor = None
		
		try:
			try:
				self._GetConnection()
				self.conn.query = query
				#Execute query and store results
				cursor = self.conn.getCursor()
				self.affectedRows = cursor.executemany(query, args)
				self.conn.updateCheckTime()
			except Exception, e:
				self.lastError = e
		finally:
			if cursor is not None:
				cursor.close()
			self._ReturnConnection()
			if self.lastError is not None:
				raise self.lastError
			else:
				return self.affectedRows
1197254
def iterateRecordInfos(dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil)
      getSchema(dbid)
      recordIDFieldName = lookupFieldNameFromID("3")
      fieldNames = getFieldNames
      fieldIDs = {}
      fieldNames.each{|name|fieldIDs[name] = lookupFieldIDByName(name)}
      iterateRecords(dbid, [recordIDFieldName], query, qid, qname, clist, slist, fmt, options){|r|
        getRecordInfo(dbid,r[recordIDFieldName])
        fieldValues = {}
        fieldIDs.each{|k,v| 
          fieldValues[k] = getFieldDataPrintableValue(v)
          fieldValues[k] ||= getFieldDataValue(v)
        }        
        yield fieldValues
      }
  end
1308128
def getRecord(rid, dbid = @dbid, fieldNames = nil)
      rec = nil
      fieldNames ||= getFieldNames(dbid)
      iterateRecords(dbid, fieldNames,"{'3'.EX.'#{rid}'}"){|r| rec = r }
      if block_given?
        yield rec
      else
        rec  
      end        
    end
119192
def execute(self):
        
        if self.query_set_obj is None:
            return []

        if self.is_mongoengine:
            result = self.query_set_obj.aggregate(*self.get_query())
        else:
            result = self.query_set_obj.aggregate(self.get_query())

        if IS_PYMONGO_3:
            result = list(result)
        else:
            result = result.get('result')
        if result:
            return result
        return []
651280
def query(sql, options=nil) #:nodoc:
      raise ArgumentError, 'query is blank' if blank? sql

      options_pattern = { :limit => :optional }
      verify_options(options, options_pattern) unless options.nil?

      limit = ''
      limit = "/#{options[:limit]}" if !options.nil? and options.include?(:limit)

      response = call_server(:method => :get, :uri => "query/#{@database}/sql/#{CGI::escape(sql)}#{limit}")
      entries = process_response(response) do
        raise NotFoundError, 'record not found' if response.body =~ /ORecordNotFoundException/
      end

      rslt = entries['result']
      # mixin all document entries (they have '@class' attribute)
      rslt.each { |doc| doc.extend Orientdb4r::DocumentMetadata unless doc['@class'].nil? }
      rslt
    end
444503
def search! query, operations = [], &block
      result = @agent_page.search query

      # FIXME on every object
      result = operations.reduce(result) do |tmp, op|
        tmp.__send__ op
      end if result

      yield result if block_given?

      result
    end