Skip to content

Instantly share code, notes, and snippets.

@lukwam
Last active March 24, 2017 18:01
Show Gist options
  • Save lukwam/1c738349ff48da61cdff90638589f01c to your computer and use it in GitHub Desktop.
Save lukwam/1c738349ff48da61cdff90638589f01c to your computer and use it in GitHub Desktop.
function to run bigquery.projects().list()
def get_projects(self, credentials):
"""Return list of BigQuery projects."""
bq = build('bigquery', 'v2', credentials=credentials)
projects = bq.projects()
request = projects.list(maxResults=10)
google_projects = []
while request is not None:
projects_list = request.execute()
google_projects += projects_list.get('projects', [])
print '%s: %s' % (len(google_projects), datetime.datetime.now())
request = projects.list_next(request, projects_list)
return google_projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment