@@ -63,7 +63,9 @@ def __request(self, method, url, params=None, payload=None):
63
63
'error' : dict (code = r .status_code , message = message )
64
64
}
65
65
66
- def get (self , table_name , record_id = None , limit = 0 , offset = None ):
66
+ def get (
67
+ self , table_name , record_id = None , limit = 0 , offset = None ,
68
+ filter_by_formula = None , view = None ):
67
69
params = {}
68
70
if check_string (record_id ):
69
71
url = os .path .join (table_name , record_id )
@@ -73,9 +75,14 @@ def get(self, table_name, record_id=None, limit=0, offset=None):
73
75
params .update ({'pageSize' : limit })
74
76
if offset and check_string (offset ):
75
77
params .update ({'offset' : offset })
78
+ if filter_by_formula is not None :
79
+ params .update ({'filterByFormula' : filter_by_formula })
80
+ if view is not None :
81
+ params .update ({'view' : view })
76
82
return self .__request ('GET' , url , params )
77
83
78
- def iterate (self , table_name , batch_size = 0 ):
84
+ def iterate (
85
+ self , table_name , batch_size = 0 , filter_by_formula = None , view = None ):
79
86
"""Iterate over all records of a table.
80
87
81
88
Args:
@@ -84,13 +91,23 @@ def iterate(self, table_name, batch_size=0):
84
91
(0) is using the default of the API which is (as of 2016-09)
85
92
100. Note that the API does not allow more than that (but
86
93
allow for less).
94
+ filter_by_formula: a formula used to filter records. The formula
95
+ will be evaluated for each record, and if the result is not 0,
96
+ false, "", NaN, [], or #Error! the record will be included in
97
+ the response. If combined with view, only records in that view
98
+ which satisfy the formula will be returned.
99
+ view: the name or ID of a view in the table. If set, only the
100
+ records in that view will be returned. The records will be
101
+ sorted according to the order of the view.
87
102
Yields:
88
103
A dict for each record containing at least three fields: "id",
89
104
"createdTime" and "fields".
90
105
"""
91
106
offset = None
92
107
while True :
93
- response = self .get (table_name , limit = batch_size , offset = offset )
108
+ response = self .get (
109
+ table_name , limit = batch_size , offset = offset ,
110
+ filter_by_formula = filter_by_formula , view = view )
94
111
for record in response .pop ('records' ):
95
112
yield record
96
113
if 'offset' in response :
0 commit comments