在python中通过BigQuery访问数据

2024-04-26 21:04:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用bigqueryapi访问python中的数据,下面是我的代码。在

我已将pem文件放在同一文件夹中,但脚本返回错误“GoogleAppClient.errors.HttpError: https://www.googleapis.com/bigquery/v2/projects/digin-1086/queries?alt=json返回“找不到:表digin-1086:dataset.my_表“>;

 from bigquery import get_client
    # BigQuery project id as listed in the Google Developers Console.
    project_id = 'digin-1086'
    # Service account email address as listed in the Google Developers Console.
    service_account = '77441948210-4fhu1kc1driicjecriqupndkr60npnh@developer.gserviceaccount.com'
    # PKCS12 or PEM key provided by Google.
    key = 'Digin-d6387c00c5a'
    client = get_client(project_id, service_account=service_account,
                        private_key_file=key, readonly=True)
    # Submit an async query.
    job_id, _results = client.query('SELECT * FROM dataset.my_table LIMIT 1000')
    # Check if the query has finished running.
    complete, row_count = client.check_job(job_id)
    # Retrieve the results.
    results = client.get_query_rows(job_id)

Tags: thekeyprojectcomclientidgetservice