1

I try to upload a few rows of data using the gcloud python library and don't succeed. Here is the sample code taken from the latest documentation

client = bigquery.Client()
dataset = client.dataset('test')
table = dataset.table("test_table")
rows = [("foo", "bar"), ("foo2", "bar2")]
result = table.insert_data(rows)

If I query the latest upload I get:

[(None, None), (None, None)]

So I add empty fields. In the documentation it says the uploaded rows should be "list of tuples", but that does not seem to work. My schema has two string fields. Unicode fields do not work either and I do not get any error result back either, which makes it difficult to debug. Any hint what I do wrong?

4

1 回答 1

1

在表中显式声明模式将有助于解决此问题。即,table = dataset.table('test_table')您应该使用以下内容,而不是 using :

left = SchemaField('left', 'STRING', 'REQUIRED') right = SchemaField('right', 'STRING', 'REQUIRED') table = dataset.table('test_table', schema=[left, right])

我在 Github 上打开了一个关于此的问题。如果有兴趣,您可以在这里阅读更多内容。

于 2016-09-30T20:47:34.140 回答