@snippet
def client_run_sync_query_paged(client, _):
 TIMEOUT_MS = 1000
 PAGE_SIZE = 100
 LIMIT = 1000
 LIMITED = ('%s LIMIT %d' % (QUERY, LIMIT))
 all_rows = []
 def do_something_with(rows):
  all_rows.extend(rows)
 query = client.run_sync_query(LIMITED)
 query.timeout_ms = TIMEOUT_MS
 query.max_results = PAGE_SIZE
 query.run()
 assert query.complete
 assert (query.page_token is not None)
 assert (len(query.rows) == PAGE_SIZE)
 assert ([field.name for field in query.schema] == ['name'])
 rows = query.rows
 token = query.page_token
 while True:
  do_something_with(rows)
  if (token is None):
   break
  (rows, total_count, token) = query.fetch_data(page_token=token)
 assert (total_count == LIMIT)
 assert (len(all_rows) == LIMIT)

@ snippet def client_run_sync_query_paged ( client , _ ) : TIMEOUT_MS = 1000 PAGE_SIZE = 100 LIMIT = 1000 LIMITED = ( '%s LIMIT %d' % ( QUERY , LIMIT ) ) all_rows = [ ] def do_something_with ( rows ) : all_rows . extend ( rows ) query = client . run_sync_query ( LIMITED ) query . timeout_ms = TIMEOUT_MS query . max_results = PAGE_SIZE query . run ( ) assert query . complete assert ( query . page_token is not None ) assert ( len ( query . rows ) == PAGE_SIZE ) assert ( [ field . name for field in query . schema ] == [ 'name' ] ) rows = query . rows token = query . page_token while True : do_something_with ( rows ) if ( token is None ) : break ( rows , total_count , token ) = query . fetch_data ( page_token = token ) assert ( total_count == LIMIT ) assert ( len ( all_rows ) == LIMIT )
run a synchronous query with paged results .