我通过python使用tyler treat(https://github.com/tylertreat/BigQuery-Python)使用bigquery客户端,代码编译时没有错误,并且对于表存在返回true,但数据插入失败。如果以下代码出现问题,请告诉我。
from oauth2client.client import flow_from_clientsecrets
from bigquery import get_client
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
import sys, os
json_key = 'key.json'
client = get_client(json_key_file=json_key, readonly=True)
exists = client.check_table('Ucare', 'try')
schema = [
{'name' : 'time', 'type': 'STRING', 'mode': 'nullable'}]
created = client.create_table('Ucare', 'try', schema)
print created
print exists
rows = [('time':'ipvbs6k16sp6bkut')]
#rows = { 'rows':[{'json':{'event_type':'_session.stop'},'insertId' : 0}]}
inserted = client.push_rows('Ucare', 'try', rows,'24556135')