python 2.7 - BigQuery Create a table from Query Results -
new big query api. trying basic query , have save table.
i not sure doing wrong below.(i have read similar questions posted topic) don't error doesn't save results in table want.
any thoughts/advice?
import argparse googleapiclient.discovery import build googleapiclient.errors import httperror oauth2client.client import googlecredentials credentials = googlecredentials.get_application_default() bigquery_service = build('bigquery', 'v2', credentials=credentials) query_request = bigquery_service.jobs() query_data = { 'query': ( 'select * ' 'from [analytics.ddewber_acq_same_day] limit 5;'), 'destinationtable':{ "projectid": 'xxx-xxx-xxx', "datasetid": 'analytics', "tableid": "ddewber_test12" }, "createdisposition": "create_if_needed", "writedisposition": "write_append", } query_response = query_request.query( projectid='xxx-xxx-xxx', body=query_data).execute()
see difference between jobs: query (that use in example) , jobs: insert (that should use) apis
hope gives direction fix code
Comments
Post a Comment