使用Python API访问Bigquery时,使用谷歌客户端API和gcloud有什么不同 [英] When accessing Bigquery using Python API, what is the difference of using google client API and gcloud

查看:116
本文介绍了使用Python API访问Bigquery时,使用谷歌客户端API和gcloud有什么不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了Python API以与google bigquery进行交互。我发现两个包提供了类似的API:Google BigQuery Client(Google API客户端包的一部分 googleapiclient )和Gcloud包 gcloud
$ b

以下是关于在BigQuery中使用这两个API的文档:
Google API客户端: googleapiclient



https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/index.html
https://cloud.google.com/bigquery/docs/reference/v2/



Google Cloud包裹: gcloud



http://googlecloudplatform.github.io/gcloud-python/stable/bigquery-usage.html a>



两种包装年龄来自谷歌,并提供与bigquery相互作用的相似功能。我有以下疑惑:


  1. 这两个软件包似乎都包含Google Cloud Platform的各种功能。在我看来,gcloud提供了命令行工具和本地环境设置。一般来说,这两个软件包有什么不同?

  2. 有没有任何这两个包之间的关系是什么?
  3. 哪个更适合访问BigQuery?

  4. 哪些工作适合?


解决方案

googleapiclient API定义(该定义是一个json文件,托管在此处。 )

因为它是自动生成的,所以如果他们试图为BigQuery编写python客户端,那么任何理智的python程序员都不会这样做。也就是说,它是API的最低级表示。



另一方面, gcloud 客户端,当谷歌试图找出客户应该看起来像BigQuery的样子时,谷歌的一群或多或少的理智人士提出了这个问题。它非常好,可以让您专注于重要的内容,而不是将BigQuery API中使用的奇怪f / v格式的结果转换为有用的内容。



另外, gcloud API的文档由文档编写者编写。 googleapiclient的文档与代码一样,是根据API定义自动生成的。

我的建议是,既使用了两者(并且大多数都没有成功地帮助设计BigQuery API来尝试使生成的客户端行为合理),那就是使用gcloud客户端。它将为您处理一系列低级细节,并且通常会让您的生活更轻松。


I searched for Python API to interact with google bigquery. And I found two packages provides similar APIs: Google BigQuery Client(Part of Google API Client Package googleapiclient) and Gcloud package gcloud.

Here are the documentation about using these two APIs for Bigquery: Google API Client:googleapiclient

https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/index.html https://cloud.google.com/bigquery/docs/reference/v2/

Google Cloud package: gcloud

http://googlecloudplatform.github.io/gcloud-python/stable/bigquery-usage.html

Both packages are from google, and provides similar functionalities interacting with bigquery. I have the following confusions:

  1. It seems both package includes a wide range of functionalities of Google Cloud Platform. In my view, gcloud provides commandline tool and local environment setup. Generally, what are the differences of these two packages?

  2. In terms of python module, what are the differences of their usage?

  3. Is there any relation between these two packages?
  4. Which is more suitable for accessing Bigquery?
  5. What kind of job are they suitable for?

解决方案

The googleapiclient client is generated directly from the raw API definition (the definition is a json file, hosted here.)

Because it is automatically generated, it is not what any sane python programmer would do if they were trying to write a python client for BigQuery. That said, it is the lowest-level representation of the API.

The gcloud client, on the other hand, was what a group of more-or-less sane folks at Google came up with when they tried to figure out what a client should look like for BigQuery. It is really quite nice, and lets you focus on what's important rather than converting results from the strange f/v format used in the BigQuery API into something useful.

Additionally, the documentation for the gcloud API was written by a doc writer. The documentation for the googleapiclient was, like the code, automatically generated from a definition of the API.

My advice, having used both (and having, mostly unsuccessfully, helped design the BigQuery API to try to make the generated client behave reasonably), is to use the gcloud client. It will handle a bunch of low-level details for you and generally make your life easier.

这篇关于使用Python API访问Bigquery时,使用谷歌客户端API和gcloud有什么不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆