def query(self, tablename, attributes=None, consistent=False, count=False,
              index=None, limit=None, desc=False, return_capacity=None,
              filter=None, filter_or=False, exclusive_start_key=None, **kwargs):
        keywords = {
            'TableName': tablename,
            'ReturnConsumedCapacity': self._default_capacity(return_capacity),
            'ConsistentRead': consistent,
            'ScanIndexForward': not desc,
            'KeyConditions': encode_query_kwargs(self.dynamizer, kwargs),
        }
        if attributes is not None:
            keywords['AttributesToGet'] = attributes
        if index is not None:
            keywords['IndexName'] = index
        if filter is not None:
            if len(filter) > 1:
                keywords['ConditionalOperator'] = 'OR' if filter_or else 'AND'
            keywords['QueryFilter'] = encode_query_kwargs(self.dynamizer,
                                                          filter)
        if exclusive_start_key is not None:
            keywords['ExclusiveStartKey'] = \
                self.dynamizer.maybe_encode_keys(exclusive_start_key)
        if not isinstance(limit, Limit):
            limit = Limit(limit)
        if count:
            keywords['Select'] = COUNT
            return self._count('query', limit, keywords)
        else:
            return ResultSet(self, limit, 'query', **keywords)