def query_records(self, table_from=None): """ Query records in a Quickbase table. This follows the patterns laid out in Quickbase query documentaiton, located here: https://help.quickbase.com/api-guide/componentsquery.html `Args:` from: str The ID of a Quickbase resource (i.e. a table) to query. `Returns:` Table Class """ req_resp = \ (self.client.request(f'{self.api_hostname}/records/query', 'POST', json={"from": table_from}).json()) resp_tbl = Table(req_resp['data']) cleaned_tbl = Table() for row in resp_tbl: row_dict = {} for column in resp_tbl.columns: row_dict[column] = row[column]['value'] cleaned_tbl.concat(Table([row_dict])) cleaned_tbl.materialize() column_resp = req_resp['fields'] column_map = {} for entry in column_resp: column_map[str(entry['id'])] = entry['label'].lower().strip() for column in cleaned_tbl.columns: cleaned_tbl.rename_column(column, column_map[column]) return cleaned_tbl
def test_materialize(self): # Simple test that materializing doesn't change the table tbl_materialized = Table(self.lst_dicts) tbl_materialized.materialize() assert_matching_tables(self.tbl, tbl_materialized)