Skip to content

nhfruchter/python-basic-bigquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A quick class I put together to access Google BigQuery data via query through Python.

  1. Go to the Google APIs console to create a new project.
  2. Services > BigQuery > status ON
  3. API Access > "Create another client ID...". Choose "Service account" and click Create.
  4. Download your private keyfile.
  5. Note down your service account's email address and project number (Overview > Project number).

Some example usage with Google ngrams:

import easybigquery
API = GoogleAPIFromServiceAccount(projectNumber, serviceEmail, pathToKeyfile)
bq = GoogleBigQuery(API)

def rawNgramData(word):
	query = "SELECT ngram, cell.volume_fraction FROM publicdata:samples.trigrams WHERE ngram CONTAINS '%s' GROUP BY ngram, cell.volume_fraction;" % word
	return bq.query(query)

print rawNgramData("robot")

About

Basic stuff for working with Google BigQuery through Google Python APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages