有没有办法在datasets.list()/ projects.list()中包含BQ云控制台(即publicdata:samples)项目下可见的公共数据集?
答案 0 :(得分:3)
是的 - 只需使用项目" publicdata "以及" 样本"的数据集Id;在您的API调用中。
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
}