pythonbq

PythonBQ

PyPI version License: MIT

Python wrapper for easy use of big query

Features

  • Easily pull big query data from python

Setup

Make sure you have Python 3.7.x (or higher) installed on your system. You can download it here.

Installation

pip install pythonbq

Example

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''')

Documentation for pythonbq Functions

https://connor-makowski.github.io/pythonbq/pythonbq.html

Output Data

  • 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 dictionaries
      • list: 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')
        
  • 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'}]
    
 1"""
 2# PythonBQ
 3[![PyPI version](https://badge.fury.io/py/pythonbq.svg)](https://badge.fury.io/py/pythonbq)
 4[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
 5
 6Python wrapper for easy use of big query
 7
 8## Features
 9
10- Easily pull big query data from python
11
12## Setup
13
14Make sure you have Python 3.7.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/).
15
16### Installation
17
18```
19pip install pythonbq
20```
21
22### Example
23```
24from pythonbq import pythonbq
25myProject=pythonbq(
26  bq_key_path='path/to/bq/key.json',
27  project_id='myGoogleProjectID',
28  legacy_sql=False
29)
30output=myProject.query(sql='''select * from myProjectTable''')
31```
32
33### Documentation for pythonbq Functions
34
35https://connor-makowski.github.io/pythonbq/pythonbq.html
36
37### Output Data
38- Output from the `query` function is returned as a list of dictionaries
39  - This can be modified by specifying the argument `out_type` in your `.query()`
40    - `dict`: list of dictionaries
41    - `list`: list of lists (header as the first row)
42    - `raw`: list of lists (with no header row)
43    - EG:
44      ```
45      output=myProject.query(sql='''select * from myProjectTable''', out_type='list')
46      ```
47- EG: 
48  ```
49  query = '''
50      SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013`
51      WHERE state = "TX"
52      LIMIT 5
53  '''
54
55  myProject = pythonbq(
56      key_path='./private/bq_key.json',
57  )
58  output = myProject.query(sql=query)
59  # output = [{'name': 'Mary'}, {'name': 'Roberta'}, {'name': 'Marguerite'}, {'name': 'Katie'}, {'name': 'Eunice'}]
60  ```"""
61from .pythonbq import pythonbq