'Querying from BigQuery to Python

I'm trying to query data to bigquery with this code as mentioned in google docs:

from google.cloud import bigquery
client = bigquery.Client()
tab = client.query(""" SELECT * FROM EXTERNAL_QUERY("projects/projectid/locations/europe-west6/connections/system", "SELECT * FROM table") """)
return render_template('index.html', tab=tab.result())

but I'm getting this error:

ValueError: ('Iterator has already started', <google.cloud.bigquery.table.RowIterator object at 0x7f86c1ef0160>)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source