#NEWLINE# def main( project_id ) : #NEWLINE# #INDENT# credentials = GoogleCredentials . get_application_default ( ) #NEWLINE# bigquery_service = build ( 'bigquery' , 'v2' , credentials = credentials ) #NEWLINE# try : #NEWLINE# #INDENT# query_request = bigquery_service . jobs ( ) #NEWLINE# query_data = { #NEWLINE# #INDENT# 'query' : 'SELECT TOP(corpus, 10) as title, COUNT(*) as unique_words FROM [publicdata:samples.shakespeare];' , #NEWLINE# #UNINDENT# } #NEWLINE# query_response = query_request . query ( projectId = project_id , body = query_data ) . execute ( ) #NEWLINE# print ( 'Query Results:' ) #NEWLINE# for row in query_response [ 'rows' ] : #NEWLINE# #INDENT# print ( '\t' . join ( ( field [ 'v' ] for field in row [ 'f' ] ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# except HttpError as err : #NEWLINE# #INDENT# print ( 'Error: {}' . format ( err . content ) ) #NEWLINE# raise err