gpt4 book ai didi

google-bigquery - 通过 API 列出公共(public)数据集

转载 作者:行者123 更新时间:2023-12-01 23:55:15 25 4
gpt4 key购买 nike

有没有办法在 datasets.list()/projects.list() 中包含 BQ 云控制台项目下可见的公共(public)数据集(即 publicdata:samples)?

最佳答案

是的 - 只需在您的 API 调用中使用项目“publicdata”和“samples”的数据集 ID。

import httplib2
from apiclient import errors
service = build('bigquery', 'v2')

# Auth (however your app does this)

tables = service.tables()
table_list = tables.list(projectId='publicdata',
datasetId='samples').execute()

从 API 控制台:

GET https://www.googleapis.com/bigquery/v2/projects/publicdata/datasets/samples/tables


{
"kind": "bigquery#tableList",
"etag": "\"asdasdsadsadsad\"",
"tables": [
{

"kind": "bigquery#table",
"id": "publicdata:samples.github_nested",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "github_nested"
},
"type": "TABLE"
},
{

"kind": "bigquery#table",
"id": "publicdata:samples.github_timeline",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "github_timeline"
},
"type": "TABLE"
},
{

"kind": "bigquery#table",
"id": "publicdata:samples.gsod",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "gsod"
},
"type": "TABLE"
},
{

"kind": "bigquery#table",
"id": "publicdata:samples.natality",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "natality"
},
"type": "TABLE"
},
{

"kind": "bigquery#table",
"id": "publicdata:samples.shakespeare",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "shakespeare"
},
"type": "TABLE"
},
{

"kind": "bigquery#table",
"id": "publicdata:samples.trigrams",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "trigrams"
},
"type": "TABLE"
},
{

"kind": "bigquery#table",
"id": "publicdata:samples.wikipedia",
"tableReference": {
"projectId": "publicdata",
"datasetId": "samples",
"tableId": "wikipedia"
},
"type": "TABLE"
}
],
"totalItems": 7
}

关于google-bigquery - 通过 API 列出公共(public)数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24066734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com