Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 为什么我们会得到一个';客户';对象没有属性';获取数据集&x27;谷歌大查询?_Python 2.7_Google App Engine_Google Bigquery - Fatal编程技术网

Python 2.7 为什么我们会得到一个';客户';对象没有属性';获取数据集&x27;谷歌大查询?

Python 2.7 为什么我们会得到一个';客户';对象没有属性';获取数据集&x27;谷歌大查询?,python-2.7,google-app-engine,google-bigquery,Python 2.7,Google App Engine,Google Bigquery,我们正在尝试为我们的Google BigQuery用户设置权限 此代码在Jupyter笔记本中运行时有效,但在应用程序引擎中不运行 from google.cloud import bigquery client = bigquery.Client.from_service_account_json(credentials, project=project) dataset = client.get_dataset(client.dataset(dataset_name)) 代码给出了以下错

我们正在尝试为我们的Google BigQuery用户设置权限

此代码在Jupyter笔记本中运行时有效,但在应用程序引擎中不运行

from google.cloud import bigquery
client = bigquery.Client.from_service_account_json(credentials, project=project)
dataset = client.get_dataset(client.dataset(dataset_name)) 
代码给出了以下错误:

“客户端”对象没有属性“get\u dataset”

我们假设这是因为AppEngine可能使用的是没有该方法的BigQuery的旧版本-但是当我们添加以下行时

print "Version: ", bigquery.__version__
,显示的版本是0.30,据我们所知,它应该支持get_dataset方法

我们错过了什么?是什么原因导致“客户端”对象没有属性“get_dataset”错误


附录:我们从dir(客户)处看到的方法有:


该库的行为就像是google cloud BigQuery,它实际上有哪些方法?您可以使用
dir(client)
查看它们。如果您打印
client.dataset(dataset\u name)
,它是什么?我想知道您是否已经拥有数据集信息,因此不需要调用类似于
client.get\u dataset
的任何东西。
>  ['SCOPE', '_SET_PROJECT', '__class__', '__delattr__', '__dict__',
> '__doc__', '__format__', '__getattribute__', '__getstate__',
> '__hash__', '__init__', '__module__', '__new__', '__reduce__',
> '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
> '__subclasshook__', '__weakref__', '_connection', '_credentials',
> '_determine_default', '_http', '_http_internal', 'copy_table',
> 'dataset', 'extract_table_to_storage', 'from_service_account_json',
> 'job_from_resource', 'list_datasets', 'list_jobs', 'list_projects',
> 'load_table_from_storage', 'project', 'run_async_query',
> 'run_sync_query']
from google.cloud import bigquery

client = bigquery.Client.from_service_account_json(credentials, project=project)

dataset = client.get_dataset(client.dataset(dataset_name))

entries = list(dataset.access_entries)
entry = bigquery.AccessEntry(
    role=role,
    entity_type=entity_type,
    entity_id=entity_id)
entries.append(entry)

dataset.access_entries = entries
dataset = client.update_dataset(dataset, ['access_entries'])
from google.cloud import bigquery

client = bigquery.Client.from_service_account_json(credentials, project=project)

dataset = client.dataset(dataset_name)
dataset.reload()

entries = list(dataset.access_grants)
entry = bigquery.AccessGrant(
    role=role,
    entity_type=entity_type,
    entity_id=entity_id)
entries.append(entry)

dataset.access_grants = entries
dataset.update()