def get_changed_records( self, db=None, clear=False ): """ Another special case of get_records(), to only return changed records (new or modified). Optionally, this will clear the change flags. """ api = 'API_DoQuery' if not db: db = self.active_db options = 'sortorder-A.onlynew' xml = ( E.qdbapi( E.ticket(self.auth_ticket), E.apptoken(self.token), E.options(options), ) ) response = self._perform(db=db, xml=xml, api=api) # Now, clear the flags if clear: self._clear_flags(db=db) return response
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)
def get_schema( self, db='' ): """ API function to get the schema for a particular database id." API_GetSchema: http://www.quickbase.com/api-guide/getschema.html """ api = 'API_GetSchema' xml = ( E.qdbapi( E.ticket(self.auth_ticket), E.apptoken(self.token), ) ) schema = self._perform(db=db, xml=xml, api=api) return schema
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)
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)