Exemple #1
0
    def get_record( self, db=None, number='' ):
        """
        Get a single record by record id.  This is non-standard, but I needed
        its functionality, and so here it is. Strictly speaking, this is just
        a special case of the get_records() function, and should be deprecated
        at some point.

        """
        api = 'API_DoQuery'
        
        if not db:
            db = self.active_db

        schema = self.get_schema(db=db)

        for node in schema.findall('table/fields/field'):
            if node.attrib['field_type'] == 'recordid':
                field = node.get('id')
                break

        query = "{'%s'.EX.'%s'}" % (field, number)

        xml = (
            E.qdbapi(
                E.ticket(self.auth_ticket),
                E.apptoken(self.token),
                E.query(query),
            )
        )

        return self._perform(db=db, xml=xml, api=api)
Exemple #2
0
    def get_records( self, db=None, conditions={} ):
        """
        API function to perform a query and return record(s) which satisfy
        the query.
        API_DoQuery:
            http://www.quickbase.com/api-guide/do_query.html
        """
        if not conditions:
            raise Exception, "No query parameters specified."

        api = 'API_DoQuery'


        if not db:
            db = self.active_db

        query = []
        schema = self.get_schema(db=db)
        
        for field in conditions:
            for f in schema.findall('table/fields/field'):
                if f.findtext('label') == field:
                    for bounds in conditions[field]:
                        query.append(
                            "{'%s'.%s.'%s'}" % (
                                f.get('id'),
                                xtn_map[bounds],
                                conditions[field][bounds]
                            )
                        )

        xml = (
            E.qdbapi(
                E.ticket(self.auth_ticket),
                E.apptoken(self.token),
                E.query('AND'.join(query)),
                E.clist('a'),
            )
        )

        return self._perform(db=db, xml=xml, api=api)
Exemple #3
0
 def get_all_records( self, db='' ):
     """
     By default, the API_DoQuery function simply returns all records
     if no conditions are satisfied.  So we do that here. This is, again,
     a special case of get_records() and should probably be deprecated.
     """
     api = 'API_DoQuery'
     
     if not db:
         db = self.active_db
         
     xml = (
         E.qdbapi(
             E.ticket(self.auth_ticket),
             E.apptoken(self.token),
             E.query(),
             E.clist('a'),
         )   
     )   
     
     return self._perform(db=db, xml=xml, api=api)