[英]Error: module 'google.cloud.bigquery_storage' has no attribute 'BigQueryReadClient'
如何修復此錯誤?
錯誤:模塊“google.cloud.bigquery_storage”沒有屬性“BigQueryReadClient”
無法查詢 BigQuery 表並將結果保存到 Pandas DataFrame。包:
google-api-core==1.23.0
google-api-python-client==1.12.8
google-auth==1.23.0
google-auth-httplib2==0.0.4
google-auth-oauthlib==0.4.1
google-bigquery==0.14
google-cloud-bigquery==2.6.1
google-cloud-bigquery-storage==2.1.0
google-cloud-core==1.4.3
google-crc32c==1.0.0
google-resumable-media==1.1.0
googleapis-common-protos==1.51.0
grpcio==1.34.0
grpcio-gcp==0.2.2
pandas==1.1.5
pandas-gbq==0.13.2
pyarrow==2.0.0
詢問:
def get_orders(bqclient,
project_id,
dataset_id,
orders_table_id,
datetime_start,
datetime_end):
query = f"""
SELECT *
FROM `{project_id}.{dataset_id}.{orders_table_id}`
WHERE
CreatedDatetime BETWEEN TIMESTAMP('{datetime_start}') AND TIMESTAMP('{datetime_end}')
"""
print(query)
orders = None
try:
query_job = bqclient.query(query)
orders = query_job.result().to_dataframe()
except Exception as exception:
print(f'Error while getting orders: {exception}')
finally:
return orders
這段代碼看起來像是在使用 google-cloud-bigquery 而不是 google-cloud-bigquery-storage。 bqclient
是如何創建的? 是這樣的嗎?
from google.cloud import bigquery
bqclient = bigquery.Client()
嘗試在您的代碼中查找對BigQueryReadClient
的引用並將其刪除。 嘗試刪除google-cloud-bigquery-storage==2.1.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.