python - Export BigQuery Data to CSV without using Google Cloud Storage -


i writing software, export large amounts of bigquery data , store queried results locally csv files. used python 3 , client provided google. did configuration , authentification, problem is, can't store data locally. everytime execute, following error message:

googleapiclient.errors.httperror: https://www.googleapis.com/bigquery/v2/projects/round-office-769/jobs?alt=json returned "invalid extract destination uri 'response/file-name-*.csv'. must valid google storage path.">

this job configuration:

def export_table(service, cloud_storage_path,              projectid, datasetid, tableid, sqlquery,              export_format="csv",              num_retries=5):  # generate unique job_id retries # don't accidentally duplicate export job_data = {     'jobreference': {         'projectid': projectid,         'jobid': str(uuid.uuid4())     },     'configuration': {         'extract': {             'sourcetable': {                 'projectid': projectid,                 'datasetid': datasetid,                 'tableid': tableid,             },             'destinationuris': ['response/file-name-*.csv'],             'destinationformat': export_format         },         'query': {             'query': sqlquery,         }     } } return service.jobs().insert(     projectid=projectid,     body=job_data).execute(num_retries=num_retries) 

i hoped use local path instead of cloud storage, store data, wrong.

so question is:

can download queried data locally(or local database) or have use google cloud storage?

you need use google cloud storage export job. exporting data bigquery explained here, check variants different path syntaxes.

then can download files gcs local storage.

gsutil tool can further download file gcs local machine.

you cannot download 1 move locally, first need export gcs, transfer local machine.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -