Query select instance information
183113
def min_query(self, query_type='list_nodes_min'):
        '''
        
        '''
        mapper = salt.cloud.Map(self._opts_defaults())
        mapper.opts['selected_query_option'] = 'list_nodes_min'
        return mapper.map_providers_parallel(query_type)
1078165
function instanceIndex(context) {
  for (var i = 0; i < instances.length; i++) {
    var instance = instances[i];
    if (instance.conversionContext === context ||
        instance.executionContext === context) {
      return i;
    }
  }
  return -1;
}
1114485
def _select_query(self):
        
        if self._where:
            self._validate_select_where()
        return SelectStatement(
            self.column_family_name,
            fields=self._select_fields(),
            where=self._where,
            order_by=self._order,
            limit=self._limit,
            allow_filtering=self._allow_filtering,
            distinct_fields=self._distinct_fields,
            fetch_size=self._fetch_size
        )
591914
def get_query_parts(self):
        
        selects = []
        aliases = []
        froms = []
        wheres = []
        sorts = []
        groups_by = []
        params = []
        app_model_labels = None
        lookup_cast = self._db_operations.lookup_cast
        qn = self._db_operations.quote_name
        uqn = self._unquote_name
        for data in self.cleaned_data:
            if not ("model" in data and "field" in data):
                break
            model = data["model"]
            # HACK: Workaround to handle tables created
            #       by django for its own
            if not app_model_labels:
                app_models = get_models(include_auto_created=True,
                                        include_deferred=True)
                app_model_labels = [u"%s_%s" % (a._meta.app_label,
                                                a._meta.model_name)
                                    for a in app_models]
            if model in app_model_labels:
                position = app_model_labels.index(model)
                model = app_models[position]._meta.db_table
                self._models[model] = app_models[position]
            field = data["field"]
            show = data["show"]
            alias = data["alias"]
            criteria = data["criteria"]
            sort = data["sort"]
            group_by = data["group_by"]
            operator, over = criteria
            olower = operator.lower()
            if 'contains' in olower:
                over = '%' + over + '%'
            elif 'endswith' in olower:
                over = '%' + over
            elif 'startswith' in olower:
                over = over + '%'

            is_join = operator.lower() == 'join'
            db_field = self.get_db_field(model, field, qn, is_join=is_join)
            if show and not is_join:
                selects.append(db_field)
            if alias is not None and not is_join:
                aliases.append(alias)
            if sort:
                sorts.append(db_field + ('' if sort == 'asc' else ' DESC'))
            if group_by:
                groups_by.append(db_field)
            if all(criteria):
                if is_join:
                    over_split = over.lower().rsplit(".", 1)
                    join_model = qn(over_split[0].replace(".", "_"))
                    join_field = qn(over_split[1])
                    join = u"%s.%s = %s" % (join_model, join_field, db_field)
                    if (join not in wheres
                            and uqn(join_model) in self._db_table_names):
                        wheres.append(join)
                        if join_model not in froms:
                            froms.append(join_model)
                    # join_select = u"%s.%s" % (join_model, join_field)
                    # if join_select not in selects:
                    #     selects.append(join_select)
                elif operator in self._db_operators:
                    # db_operator = self._db_operators[operator] % over
                    db_operator = self._db_operators[operator]
                    lookup = self._get_lookup(operator, over)
                    params.append(lookup)
                    wheres.append(u"%s %s"
                                  % (lookup_cast(operator) % db_field,
                                     db_operator))
                elif operator in self._custom_operators:
                    CustOperator = self._custom_operators[operator]
                    custom_operator = CustOperator(db_field, operator, over)

                    # make sure the operators params are iterable:
                    custom_params = custom_operator.get_params()
                    if isinstance(custom_params, collections.Iterable):
                        params += custom_params
                    else:
                        params += [custom_params, ]

                    # make sure the operators wheres are iterable:
                    custom_wheres = custom_operator.get_wheres()
                    if isinstance(custom_wheres, collections.Iterable):
                        wheres += custom_wheres
                    else:
                        wheres += [custom_wheres, ]

            if qn(model) not in froms and model in self._db_table_names:
                froms.append(qn(model))
        return selects, aliases, froms, wheres, sorts, groups_by, params
1302293
private static void selectWithQueryBuilder(CqlSession session) {
    // Reading the whole row as a JSON object:
    Statement stmt =
        selectFrom("examples", "querybuilder_json")
            .json()
            .all()
            .whereColumn("id")
            .isEqualTo(literal(1))
            .build();
    Row row = session.execute(stmt).one();
    assert row != null;
    System.out.printf("Entry #1 as JSON: %s%n", row.getString("[json]"));

    // Extracting a particular column as JSON:
    stmt =
        selectFrom("examples", "querybuilder_json")
            .column("id")
            .function("toJson", Selector.column("specs"))
            .as("json_specs")
            .whereColumn("id")
            .isEqualTo(literal(2))
            .build();

    row = session.execute(stmt).one();
    assert row != null;

    System.out.printf(
        "Entry #%d's specs as JSON: %s%n", row.getInt("id"), row.getString("json_specs"));
  }
1041224
def query_info(self, what):
        
        if not isinstance(what, baseinteger):
            raise TypeError("what can only be an instance of type baseinteger")
        result = self._call("queryInfo",
                     in_p=[what])
        return result
1193690
def query(
            self,
            select_column_names,
            filter_column,
            filter_value,
            feature,
            distinct=False,
            required=False):
        
        sql = """
            SELECT %s%s
            FROM %s
            WHERE %s = ?
        """ % ("distinct " if distinct else "",
               ", ".join(select_column_names),
               feature,
               filter_column)
        query_params = [filter_value]
        return self.run_sql_query(
            sql, required=required, query_params=query_params)
952218
def query_names(self, name, like, kind):
        
        kind = self._make_kind_id(kind)
        sql = 'select id, name from files ' \
              'where leaf_name {} ?'.format('like' if like else '=')
        args = (name,)
        if like:
            sql += ' escape ?'
            args = (name, '\\')
        logging.debug('%s %s', sql, args)
        self.cursor.execute(sql, args)
        ids = self.cursor.fetchall()
        files = []
        for file_id, header in ids:
            sql = 'select name from code_items ' \
                  'where file_id = ?'
            args = (file_id,)
            if kind:
                sql += 'and kind = ?'
                args = (file_id, kind)
            logging.debug('%s %s', sql, args)
            self.cursor.execute(sql, args)
            files.append((header, self.cursor.fetchall()))
        return files
174675
def select_all(self, table, limit=MAX_ROWS_PER_QUERY, execute=True):
        """"""
        # Determine if a row per query limit should be set
        num_rows = self.count_rows(table)
        if num_rows > limit:
            return self._select_batched(table, '*', num_rows, limit, execute=execute)
        else:
            return self.select(table, '*', execute=execute)
1130138
def _query_select_options(self, query, select_columns=None):
        
        if select_columns:
            _load_options = list()
            for column in select_columns:
                if "." in column:
                    model_relation = self.get_related_model(column.split(".")[0])
                    if not self.is_model_already_joinded(query, model_relation):
                        query = query.join(model_relation)
                    _load_options.append(
                        Load(model_relation).load_only(column.split(".")[1])
                    )
                else:
                    if not self.is_relation(column) and not hasattr(
                        getattr(self.obj, column), "__call__"
                    ):
                        _load_options.append(Load(self.obj).load_only(column))
                    else:
                        _load_options.append(Load(self.obj))
            query = query.options(*tuple(_load_options))
        return query
1154146
def __query_spec(self):
        """"""
        spec = self.__spec
        if not self.__is_command and "$query" not in self.__spec:
            spec = SON({"$query": self.__spec})
        if self.__ordering:
            spec["$orderby"] = self.__ordering
        if self.__explain:
            spec["$explain"] = True
        if self.__hint:
            spec["$hint"] = self.__hint
        if self.__comment:
            spec["$comment"] = self.__comment
        if self.__snapshot:
            spec["$snapshot"] = True
        if self.__max_scan:
            spec["$maxScan"] = self.__max_scan
        return spec
668475
def select(cls, *args, **kwargs):
        """"""
        query = super(Model, cls).select(*args, **kwargs)
        query.database = cls._get_read_database()
        return query
1267756
def instances
      @instances ||= begin
        if $DEBUG
          puts 'Entering instance_ids'
          puts "Search Term: #{search_terms.inspect}"
        end

        instance_ids = search_terms.each_with_object([]) do |search_term, m|
          if (/^i-/ =~ search_term) && !(/\./ =~ search_term)
            m << search_term
          else
            ec2.servers.each do |server|
              next unless server.tags.key?('Name') \
                && (server.tags['Name'] != '') \
                && (/#{search_term}/i =~ server.tags['Name'])

              m << server.id
            end
          end
        end

        if instance_ids.empty?
          puts 'No instances by that Name/ID in this account'
          exit 1
        end

        puts "Found instances: #{instance_ids.inspect}" if $DEBUG

        ec2.servers.all 'instance-id' => instance_ids
      end
    end
520774
def _get_access_info(self, instance, db_key, db_name=None):
        ''' 
        '''
        dsn = instance.get('dsn')
        host = instance.get('host')
        username = instance.get('username')
        password = instance.get('password')
        database = instance.get(db_key) if db_name is None else db_name
        driver = instance.get('driver')
        if not dsn:
            if not host:
                host = '127.0.0.1,1433'
            if not database:
                database = self.DEFAULT_DATABASE
            if not driver:
                driver = self.DEFAULT_DRIVER
        return dsn, host, username, password, database, driver
994174
def _order_queries(self):
        """"""
        from .condition import Order
        order = []
        for column in self.columns:
            if column.order_by:
                o = Order(self.cls, column.attr, column.order_by)
                order.append(o.__query__())
        if not order:
            k = self.columns[0].attr
            o = Order(self.cls, k)
            self.columns[0].order_by = o.order
            order.append(o.__query__())
        return order
84517
def info(self):
        
        unique_indexes = set(self._uniqueIndexes)
        return {
            'len': len(self),
            'name': self.table_name,
            'fields': list(_object_attrnames(self[0])) if self else [],
            'indexes': [(iname, self._indexes[iname] in unique_indexes) for iname in self._indexes],
        }
1179523
def perfom_query(iterator, &block)
      if example
        connection.by_example(example, options).each(&iterator)
      else
        connection.all(options).each(&iterator)
      end
    end