Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.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 Google Biq查询某物返回空/无行_Python_Google App Engine_Google Api_Google Bigquery - Fatal编程技术网

Python Google Biq查询某物返回空/无行

Python Google Biq查询某物返回空/无行,python,google-app-engine,google-api,google-bigquery,Python,Google App Engine,Google Api,Google Bigquery,使用PythonAPI查询大查询有时会返回无响应或无行。尽管再次重试相同的查询也可以。原因是什么 def execute(self,bq_query,query_type,uid): self.cache = cache.Cache() cached_response = self.cache.get(bq_query) if(cached_response is not None): query_response = json.loads(zlib.d

使用PythonAPI查询大查询有时会返回无响应或无行。尽管再次重试相同的查询也可以。原因是什么

def execute(self,bq_query,query_type,uid):
    self.cache = cache.Cache()

    cached_response = self.cache.get(bq_query)
    if(cached_response is not None):
        query_response = json.loads(zlib.decompress(cached_response))
        app.logger.info("cached")
    else:
        big_query=_BigQuery(uid)
        query_response = big_query.run_in_big_query(bq_query)
        if not query_response:
            logging.warning('**************************1.No reponse')
            abort(404)
        elif 'rows' not in query_response.keys():
            logging.warning('**************************2.No rows')
            abort(404)



def run_in_big_query(self, sql):
    start = time.time()
    queryData = {'query': sql}
    queryRequest = self.service.jobs()
    queryResponse = queryRequest.query(projectId=project_id, 
body=queryData).execute()
    app.logger.info('Query Time %f' % (time.time() - start))
    return queryResponse

query方法将查询作业插入到BigQuery中。默认情况下,查询方法以
10s
for运行。指定非零超时值时,作业将等待结果,并在超时时引发异常

阅读更多关于

  • 同步查询
  • 异步查询

还有Python代码,如何轮询直到作业完成