Google Custom Search

2021/08/22

把google sheets 當作 bigquery的table

 很多方式可以把資料匯入bigquery的table, google sheet是其中之一,好處是sheet變動可以直接呈現在table裡。

把google sheets加入到bigquery要先把bigquery 的 project 的 service account 加入 google sheets 的share 名單,然後到 bigquery 新增table,填上sheets的分享網址並設定需要的欄位範圍,這樣就能直接在bigquery裡查詢了。





如果要透過api存取,記得在biqquery的初始化加入google drive的scope,這樣就不會遇到沒有權限的錯誤。

$bigQuery = new BigQueryClient(

    [

        'projectId' => $projectId, 

        'scopes' => array(

            "https://www.googleapis.com/auth/drive",

            "https://www.googleapis.com/auth/bigquery",

        )

    ]

);


沒有留言 :