Is there a way to include public datasets that are visible under a project in BQ cloud console (i.e. publicdata:samples) in datasets.list() / projects.list() ?
Yes - just use project "publicdata" and the datasetId of "samples" in your API calls.
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()
From the API Console:
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With