BigQuery API是否有一些重大变化

问题描述 投票:0回答:1

两个月前,我很好地运行了以下代码,但是现在,在我再次安装google.cloud之后,它被说:'TableReference'对象没有属性“存在”,要么我不能使用Dataset.name,它也走了。所以有关API声音的任何重大变化,比如我需要重构我的代码......

def createTable(client, ds, tb):
    dataset = client.dataset(ds)
   #assert not dataset.exists()
    table = dataset.table(tb)
    #assert not table.exists()
    if not table.exists():
        assert not table.exists()
        table.schema = (bigquery.SchemaField('Name', 'STRING'),
                        bigquery.SchemaField('Age', 'INTEGER'),
                        bigquery.SchemaField('Weight', 'FLOAT'),)
        table.create()
    else:
        print 'this table already existed in this dataset'
        assert table.exists()
google-bigquery
1个回答
2
投票

您可能暂时没有更新,并且您从0.28.0引入了重大更改,特别是:

删除table.exists()(#4145)

用于创建,获取,更新,删除移动到客户端类的数据集和表的函数。

看到:

总之,您需要迁移/移植代码,或者保留旧版本。

© www.soinside.com 2019 - 2024. All rights reserved.