2015-06-11 30 views

回答

6

在Python可以運行在表API端點插入的工作,因爲它的記錄here您將創建一個空表需要提供一個TableResource

project_id = <my project> 
dataset_id = <my dataset> 
table_id = 'table_001' 
dataset_ref = {'datasetId': dataset_id, 
       'projectId': project_id} 
table_ref = {'tableId': table_id, 
      'datasetId': dataset_id, 
      'projectId': project_id} 
schema_ref = {<schema comes here>} 
table = {'tableReference': table_ref, 
     'schema': schema_ref} 
table = bigquery.tables().insert(
    body=table, **dataset_ref).execute(http) 

** dataset_ref是一個Python把戲內容複製到命名參數

瀏覽其他python + bigquery問題。

+2

{<模式來到這裏>}是如何被重新獲得的?它是JSON是這樣的: 「綱目」:{ 「田」: { 「名」:字符串, 「類型」:字符串, 「模式」:字符串, 「田」: (TableFieldSchema) ], 「description」:string } ] –

+0

請參閱https://code.google.com/p/bigquery-e2e/source/browse/samples/ch05/tour.py#75以獲取設置架構。 –

+2

鏈接已死。這是更新的:https://github.com/j450h1/bigquery-e2e/blob/master/samples/ch05/tour.py – akhmed