Database Reference
In-Depth Information
# Imports from files in this directory:
import auth
READ_CHUNK_SIZE= 64 * 1024
class ResultHandler:
'''Abstract class to handle reading TableData
rows.'''
def handle_rows(self, rows):
'''Process one page of results.'''
pass
class TableReader:
'''Reads data from a BigQuery table.'''
def __init__(self, project_id, dataset_id, table_id,
start_index=None, read_count=None,
next_page_token=None):
self.project_id = project_id
self.dataset_id = dataset_id
self.bq_service = auth.build_bq_client()
self.next_page_token = next_page_token
self.next_index = start_index
self.rows_left = read_count
self.table_id = table_id
def get_table_info(self):
'''Returns a tuple of (modified time, row count)
for the table.'''
table = self.bq_service.tables().get(
projectId=self.project_id,
datasetId=self.dataset_id,
tableId=self.table_id).execute()
last_modified = int(table.get('lastModifiedTime',
0))
row_count = int(table.get('numRows', 0))
Search WWH ::




Custom Search