A collection of BigQuery utilities
Project description
bq-utils - A collection of BigQuery utilities
Currently the utilities covered in this library are limited to managing table and view descriptions. It's quite useful to have the field descriptions available on the schema tab and on the query editor pane on the BigQuery UI and this library helps you with uploading them and copying them around.
Install
pip install bq-utils
Python
Copy descriptions between tables and views
from google.cloud import bigquery
from bqutils.bigquery_description_manager import BigQueryDescriptionManager
bq_client = bigquery.Client()
description_manager = BigQueryDescriptionManager(bq_client)
source_table_id = 's_project.s_dataset.s_table'
target_table_id = 't_project.t_dataset.t_table'
description_manager.copy_field_descriptions(source_table_id, target_table_id)
Upload descriptions from csv
from google.cloud import bigquery
from bqutils.bigquery_description_manager import BigQueryDescriptionManager
bq_client = bigquery.Client()
description_manager = BigQueryDescriptionManager(bq_client)
descriptions_csv_path = 'table_descriptions.csv'
target_table_id = 't_project.t_dataset.t_table'
description_manager.upload_field_descriptions(descriptions_csv_path, target_table_id)
Command line
Usage
usage: __main__.py [-h] [--source SOURCE] --target TARGET
[--csv_path CSV_PATH] [--debug]
{desccopy,descupload}
Copy or upload field descriptions for BigQuery tables/views
positional arguments:
{desccopy,descupload}
optional arguments:
-h, --help show this help message and exit
--source SOURCE fully-qualified source table ID
--target TARGET fully-qualified target table ID
--csv_path CSV_PATH path for the csv file
--debug set debug mode on, default is false
Copy descriptions between tables and views
python -m bqutils desccopy --source s_project.s_dataset.s_table --target t_project.t_dataset.t_table
Upload descriptions from csv
python -m bqutils descupload --csv_path table_descriptions.csv --target t_project.t_dataset.t_table
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bq-utils-0.1.1.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file bq-utils-0.1.1.tar.gz
.
File metadata
- Download URL: bq-utils-0.1.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfde1a9e9112051d7bcd19e7c3ef9033f0cb7cc1d6e39fffe33e24ddf0cc3c8c |
|
MD5 | 07318e3befd83ba5faf78b5e8ae1617e |
|
BLAKE2b-256 | 1a80af5ca17454060fad306a79b5660663cb48a04faec457bc96fb5e73083a8d |
File details
Details for the file bq_utils-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: bq_utils-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71edc805b794b5c417a88446e40180328c0a97dfcb868ee04b5f9322bf77690d |
|
MD5 | 75474b08005c94085f4c08351c971df9 |
|
BLAKE2b-256 | 5f891fba643ee621973ea02fe46366ef4d794d5d6f2c041880eaeafdf6dc30fe |