python - 通过 Python API 创建 Bigquery 表

标签 python google-bigquery

我正在尝试使用 Python API 创建一个 Bigquery 表。

from google.cloud import bigquery

bigquery_client = bigquery.Client(project="myproject")
dataset = bigquery_client.dataset("mydataset")

table = dataset.table("mytable")
table.create()

我一直收到这个错误

AttributeError: 'TableReference' object has no attribute 'create'

有人知道吗?

最佳答案

在倒数第二行 (table = dataset.table("mytable"))。你需要这样做:

[..]
table_ref = dataset.table('my_table')
table = bigquery.Table(table_ref, schema=SCHEMA)
table = client.create_table(table)
[..]

参见 here .

关于python - 通过 Python API 创建 Bigquery 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47826086/

相关文章:

python - Selenium 仅在 DOM 完全加载时才执行 javascript

sql - 如何在 BigQuery 的新 SQL 查询中连接/使用已保存的查询

python - 如何在Python中打印下划线变量?

java - NLTK 和 MaltParser 退出,错误代码为 1

python - 带有三重引号的 Jupyter Notebook Python 自动文档字符串生成

python - 如何对不同的迭代值求和?

google-bigquery - 使用 BQ API 使用 Write_Truncate 将数据加载到 “Partitioned Tables”

python - Dataflow Streaming 使用 Python SDK : Transform for PubSub Messages to BigQuery Output

python - 使用 Pandas 将数据覆盖到 BigQuery

google-bigquery - 如何在Google BigQuery中获取日期名称