Python wrapper for easy use of big query
- Easily pull big query data from python
Make sure you have Python 3.7.x (or higher) installed on your system. You can download it here.
pip install pythonbq
from pythonbq import pythonbq
myProject=pythonbq(
bq_key_path='path/to/bq/key.json',
project_id='myGoogleProjectID',
legacy_sql=False
)
output=myProject.query(sql="""select * from myProjectTable""")
https://connor-makowski.github.io/pythonbq/pythonbq.html
- Output from the
query
function is returned as a list of dictionaries- This can be modified by specifying the argument
out_type
in your.query()
dict
: list of dictionarieslist
: list of lists (header as the first row)raw
: list of lists (with no header row)- EG:
output=myProject.query(sql="""select * from myProjectTable""", out_type='list')
- This can be modified by specifying the argument
- EG:
query = """ SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` WHERE state = "TX" LIMIT 5 """ myProject = pythonbq( key_path='./private/bq_key.json', ) output = myProject.query(sql=query) # output = [{'name': 'Mary'}, {'name': 'Roberta'}, {'name': 'Marguerite'}, {'name': 'Katie'}, {'name': 'Eunice'}]