Query an entry to the topology DB.
199717
def query_topology_db(self, dict_convert=False, **req):
        
        session = db.get_session()
        with session.begin(subtransactions=True):
            try:
                # Check if entry exists.
                topo_disc = session.query(DfaTopologyDb).filter_by(**req).all()
            except orm_exc.NoResultFound:
                LOG.info("No Topology results found for %s", req)
                return None
        if dict_convert:
            return self._convert_topo_obj_dict(topo_disc)
        return topo_disc
215041
def get_db(cls):
        """"""
        if cls._db:
            return getattr(cls._client, cls._db)
        return cls._client.get_default_database()
534520
def _query(self):
        '''
        
        '''
        query = salt.utils.stringutils.to_bytes(
            "{}{}".format(self.signature, time.time()))
        self._socket.sendto(query, ('<broadcast>', self.port))

        return query
435828
def query(qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
          tcp=False, source=None, raise_on_no_answer=True, resolver=None):
    """"""
    if resolver is None:
        resolver = get_default_resolver()
    return resolver.query(qname, rdtype, rdclass, tcp, source, raise_on_no_answer)
62375
def query(self, query):
    ''''''
    query = query.copy()
    query.key = self._transform(query.key)
    return self.child_datastore.query(query)
310624
def _get_query(self, callback, schema, query=None, *args, **kwargs):
        """"""
        if not query: query = Query()

        ret = None
        with self.connection(**kwargs) as connection:
            kwargs['connection'] = connection
            try:
                if connection.in_transaction():
                    # we wrap SELECT queries in a transaction if we are in a transaction because
                    # it could cause data loss if it failed by causing the db to discard
                    # anything in the current transaction if the query isn't wrapped,
                    # go ahead, ask me how I know this
                    with self.transaction(**kwargs):
                        ret = callback(schema, query, *args, **kwargs)

                else:
                    ret = callback(schema, query, *args, **kwargs)

            except Exception as e:
                exc_info = sys.exc_info()
                if self.handle_error(schema, e, **kwargs):
                    ret = callback(schema, query, *args, **kwargs)
                else:
                    self.raise_error(e, exc_info)

        return ret
253091
def _query(self):
        

        if not self.urls:
            self._resp = {}

        elif self._resp is None:
            params = [ ('url', url) for url in self.urls]
            query = urllib.urlencode(params)

            # query API
            r = self.opener.open(BITLOVE_ENCLOSURE_API + query)
            self._resp = json.loads(r.read())
955855
def query(self):
    """"""
    if not self.exists():
      return None
    self._table._load_info()
    if 'view' in self._table._info and 'query' in self._table._info['view']:
      return _query.Query(self._table._info['view']['query'])
    return None
699889
def query(self):
        """"""
        self._query = query = ""

        query_kwargs = self.query_kwargs
        if query_kwargs: query = urlencode(query_kwargs, doseq=True)
        return query
310798
def _query_db(self, mapping):
        
        model = self.models[mapping.get("table")]

        # Use primary key instead of the field mapped to SF Id
        fields = mapping.get("fields", {}).copy()
        if mapping["oid_as_pk"]:
            del fields["Id"]
        id_column = model.__table__.primary_key.columns.keys()[0]
        columns = [getattr(model, id_column)]

        for f in fields.values():
            columns.append(model.__table__.columns[f])
        lookups = mapping.get("lookups", {}).copy()
        for lookup in lookups.values():
            lookup["aliased_table"] = aliased(
                self.metadata.tables["{}_sf_ids".format(lookup["table"])]
            )
            columns.append(lookup["aliased_table"].columns.sf_id)

        query = self.session.query(*columns)
        if "record_type" in mapping and hasattr(model, "record_type"):
            query = query.filter(model.record_type == mapping["record_type"])
        if "filters" in mapping:
            filter_args = []
            for f in mapping["filters"]:
                filter_args.append(text(f))
            query = query.filter(*filter_args)
        for sf_field, lookup in lookups.items():
            # Outer join with lookup ids table:
            # returns main obj even if lookup is null
            key_field = get_lookup_key_field(lookup, sf_field)
            value_column = getattr(model, key_field)
            query = query.outerjoin(
                lookup["aliased_table"],
                lookup["aliased_table"].columns.id == value_column,
            )
            # Order by foreign key to minimize lock contention
            # by trying to keep lookup targets in the same batch
            lookup_column = getattr(model, key_field)
            query = query.order_by(lookup_column)
        self.logger.info(str(query))
        return query
1189497
def query(self, query):
    ''''''
    results = super(SymlinkDatastore, self).query(query)
    return self._follow_link_gen(results)
1269842
def get_queryset(self):
        
        qs = LogEntry.objects.all()
        content_id = get_query_params(self.request).get("content", None)
        if content_id:
            qs = qs.filter(object_id=content_id)
        return qs
527328
def __query(self, query):
        
        # Switch to lxml for querying
        xml = self.document.toxml()
        return OneLogin_Saml2_Utils.query(fromstring(xml, forbid_dtd=True), query)
1183316
def add_update_topology_db(self, **params):
        
        topo_dict = params.get('columns')
        session = db.get_session()
        host = topo_dict.get('host')
        protocol_interface = topo_dict.get('protocol_interface')
        with session.begin(subtransactions=True):
            try:
                # Check if entry exists.
                session.query(DfaTopologyDb).filter_by(
                    host=host, protocol_interface=protocol_interface).one()
                session.query(DfaTopologyDb).filter_by(
                    host=host, protocol_interface=protocol_interface).update(
                    topo_dict)
            except orm_exc.NoResultFound:
                LOG.info("Creating new topology entry for host "
                         "%(host)s on Interface %(intf)s",
                         {'host': host, 'intf': protocol_interface})
                topo_disc = DfaTopologyDb(
                    host=host, protocol_interface=protocol_interface,
                    phy_interface=topo_dict.get('phy_interface'),
                    created=topo_dict.get('created'),
                    heartbeat=topo_dict.get('heartbeat'),
                    remote_mgmt_addr=topo_dict.get('remote_mgmt_addr'),
                    remote_system_name=topo_dict.get('remote_system_name'),
                    remote_system_desc=topo_dict.get('remote_system_desc'),
                    remote_port_id_mac=topo_dict.get('remote_port_id_mac'),
                    remote_chassis_id_mac=topo_dict.get(
                        'remote_chassis_id_mac'),
                    remote_port=topo_dict.get('remote_port'),
                    remote_evb_cfgd=topo_dict.get('remote_evb_cfgd'),
                    remote_evb_mode=topo_dict.get('remote_evb_mode'),
                    configurations=topo_dict.get('configurations'))
                session.add(topo_disc)
            except orm_exc.MultipleResultsFound:
                LOG.error("More than one enty found for agent %(host)s."
                          "Interface %(intf)s",
                          {'host': host, 'intf': protocol_interface})
            except Exception as exc:
                LOG.error("Exception in add_update_topology_db %s", exc)
1017284
def query(self, queryString):
    '''
    
    '''
    self._setHeaders('query')
    return self._sforce.service.query(queryString)
1303643
def get_database(obj, **params):
    """"""
    if isinstance(obj, string_types):
        return connect(obj, **params)
    return obj
406799
def _get_topology(self):
        
        self._topology.open()
        with self.__lock:
            self._kill_cursors_executor.open()
        return self._topology