Skip to main content

PyGBQ

Easily integrate data in BigQuery

Example

The following snippet

from pygbq import Client
import requests
client = Client(default_dataset='Finance')

def transactions(start_date):
    data = requests.get(url='some/api/endpoint', headers={'start_date': start_date}).json()
    client.update_table_using_temp(data=data, table_id='transactions', how=['id'])
    return {'status': 200}

if __name__ == "__main__":
    transactions("2020-11-25")

will upsert data to table Finance.transactions by id.

Install and set up

pip install pygbq

Set up the authentication.

Documentation

  • Client - you can set default_dataset, save_dir, path_to_key
  • Client.update_table_using_temp - the main update function, use how='insert' to insert data and how=['field1', 'field2'] to upsert (merge) by field1 and field2
  • read_jsonl - read newline delimited json
  • Client.get_secret - get a secret version from Secret Manager
  • Client.add_secret - add a secret version to Secret Manager

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygbq-0.24.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygbq-0.24-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file pygbq-0.24.tar.gz.

File metadata

  • Download URL: pygbq-0.24.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for pygbq-0.24.tar.gz
Algorithm Hash digest
SHA256 177adf6b2bcb20d618e43fca4c2449f854a374d29dddcc73cb4b390cc53c42d6
MD5 632559f03c1691869b02dde2722a93d9
BLAKE2b-256 9dd5f519ec2056189f525edac0c5b5c002f616656a64f73ed25e3253ee041caa

See more details on using hashes here.

File details

Details for the file pygbq-0.24-py3-none-any.whl.

File metadata

  • Download URL: pygbq-0.24-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for pygbq-0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 bc074a130c837e1f2eed1edeca395f0037e4149097987ecc92bf4a93e7939b0f
MD5 0ea1039bf9522fe2bacd1c17f63bca70
BLAKE2b-256 0664c3132d2aeaf439de1445c3348ea0b35fdc7fce7ff52a702755a33f336782

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page