' QueryResults'对象没有属性'结果'

时间:2018-01-21 05:34:51

标签: sql google-bigquery jupyter-notebook

render(
    <Provider store={store}>
        <App>
            <SomeComponentInMyApp />
        </App>
    </Provider>,
    document.getElementById('content-wrapper')
);

我试图在jupyter笔记本中运行上面的代码,但系统给出了&#34; AttributeError:&#39; QueryResults&#39;对象没有属性&#39;结果&#39;&#34;

我找不到要替换结果对象的文档。

(现有文档https://cloud.google.com/bigquery/create-simple-app-api已过时,因为run_sync_query也正在替换run_query) 你能救我吗?

1 个答案:

答案 0 :(得分:2)

我做了一些更改以使用您提供的第二个示例进行调整,这对我有用。代码:

<div class="x">
  <div class="x-header">This is a header</div>
  <div class="x-body">
    <div class="x-structure-2-columns">
      <div class="x-structure-2-columns-left">
        LEFT
      </div>
      <div class="x-structure-2-columns-right">
        <div class="x-structure-2-columns-right-header">SUB NAVIGATION</div>
        <div class="x-structure-2-columns-right-body">
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
          <p>123
            <br>345
            <br>678</p>
        </div>
      </div>
    </div>
  </div>
</div>

输出:

from google.cloud import bigquery


client = bigquery.Client()

QUERY = ("""
    SELECT
      CONCAT(
        'https://stackoverflow.com/questions/',
        CAST(id as STRING)) as url,
       view_count
    FROM `bigquery-public-data.stackoverflow.posts_questions`
    WHERE tags like '%google-bigquery%'
ORDER BY view_count DESC
LIMIT 10""")
query_job = client.query(QUERY)

iterator = query_job.result()
rows = list(iterator)

for row in rows:
    print row