Package codes to execute queries on BQ and save to local machine, to BQ table or to GCS.
Project description
Credit
This repository is forked from https://github.com/IcarusSO/bigQueryExporter
Change Log (Compare with original version)
query_to_local()
- Create a temp table with a random hash on BQ as output table, so that simultaneous execution of the function will not overwrite each other.
- Remove the temp table after the execution. (May also set keep_temp_table=True if you wish to keep them).
bigQueryExporter
Export query data from google bigquery to local machine
Installation
pip install bigQueryExporterEnhanced
Prepare for the connection
from bigQueryExport import BigQueryExporter
bigQueryExporter = BigQueryExporter(project_name, dataset_name, bucket_name)
Query To Table
bigQueryExporter.query_to_table(query, job_name, dataset_name)
Table To GS
bigQueryExporter.table_to_gs(destination_table, job_name)
GS To Local
bigQueryExporter.gs_to_local(bucket, job_name, data_dir_path)
Query To GS (Query to Table + Table to GS)
bigQueryExporter.query_to_gs(query, job_name)
Query To Local (Query to Table + Table to GS + GS to Local)
export_path = bigQueryExporter.query_to_local(query)
# or with the options
export_path = bigQueryExporter.query_to_local(query,
job_name='simple_query',
data_dir_path='out/',
keep_temp_table=False,
overwrite_output_folder=True)
Requirement
-
Your server/ local machine should have the right to access the project
-
Right should be granted following the insturction on Google SDK
-
Execute the following command
gcloud auth application-default login
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bigQueryExporterEnhanced-1.0.8.tar.gz
.
File metadata
- Download URL: bigQueryExporterEnhanced-1.0.8.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.19.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a31f0148aed43cc074a0638d6c96a4b018a581b0a9af1a4946c4cbe4a1b62f82 |
|
MD5 | c44d780be539977caa0738b58ae1ae1b |
|
BLAKE2b-256 | 9ddcc689a03ec32db0c0f389fe489f674fbfc5ffa5777546911a45c62ed440c2 |
File details
Details for the file bigQueryExporterEnhanced-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: bigQueryExporterEnhanced-1.0.8-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.19.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4db046decf0b02fbdf534133dcd251f025d31c96e0c08488b31f38740e1d8758 |
|
MD5 | 7117b314741f4ce562e8819d55b13d91 |
|
BLAKE2b-256 | 8f77306cdf22923761a241e350cd31b72ecabef397db7e598447b22aa50610cf |