【问题标题】:How to activate API Bigquery in GCP with python?如何使用 python 在 GCP 中激活 API Bigquery?
【发布时间】:2022-12-18 17:26:24
【问题描述】:

我正在 gcp 中开发一个小应用程序,我必须激活 bigquery api 才能与之交互,我通过控制台进行操作,但是,是否可以使用 python google api 客户端进行操作?

我一直在查看文档,但我仍然不清楚。

【问题讨论】:

  • 请阐明您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
  • 这是通过the services API完成的。

标签: python google-cloud-platform google-bigquery


【解决方案1】:

从控制台启用BigQuery API

  • 转到控制台.google.com
  • 从菜单中,单击API 和服务 -> 启用 API 和服务
  • 点击启用 API 和服务
  • 搜索大查询 API然后点击启用

通过gcloud sdk启用:

gcloud services enable bigquery.googleapis.com

您可能还需要启用其他与 BigQuery 相关的 API:

bigquery.googleapis.com                BigQuery API
bigqueryconnection.googleapis.com      BigQuery Connection API
bigquerydatatransfer.googleapis.com    BigQuery Data Transfer API
bigquerymigration.googleapis.com       BigQuery Migration API
bigquerystorage.googleapis.com         BigQuery Storage API

通过 python REST refer this documentation 启用服务

要使用 Python 客户端库与 BigQuery 交互/工作:

安装Python Client library for BigQuery

install google-cloud-bigquery

查询堆栈溢出公共数据集:

from google.cloud import bigquery

client = bigquery.Client()

# Perform a query.
QUERY = ("SELECT title FROM `bigquery-public-data.stackoverflow.posts_questions` LIMIT 10")
query_job = client.query(QUERY)  # API request
rows = query_job.result()  # Waits for query to finish

for row in rows:
    print(row.name)

参考资料:BigQuery QuickStart using client libraries

【讨论】:

    猜你喜欢
    • 2016-07-07
    • 1970-01-01
    • 2022-01-26
    • 2020-08-25
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2019-11-30
    • 1970-01-01
    相关资源
    最近更新 更多