0

I am looking for creating a JSON format for an API that gets statistics from PyPi but from PyPi public dataset. But, I do not know what exacly is happening, but I am getting all the time:

google.api_core.exceptions.Forbidden: 403 Quota exceeded: Your project exceeded quota for free query bytes scanned. For more information, see https://cloud.google.com/bigquery/docs/troubleshoot-quotas

For this:

def get_packages_from_bigquery(): 

    #  bigquery-public-data.pypi
    # bigquery-public-data.pypi.file_downloads

    credentials = Credentials.from_service_account_file('fuheufehfiewu.json')
    client = bigquery.Client(credentials=credentials, project="rheuwrhewiurehwi")

    query = """
    SELECT project AS package_name, COUNT(*) AS download_count
    FROM `bigquery-public-data.pypi.file_downloads`
    WHERE DATE(timestamp) >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
    GROUP BY package_name
    ORDER BY download_count DESC
    LIMIT 50
    """

    result = client.query(query).result()

    # Convert the result to a list of dictionaries
    packages = [{'name': row.package_name, 'downloads': row.download_count} for row in result]

    # Convert the list of dictionaries to a JSON string
    return json.dumps(packages)

Am I in the right path? What is wrong with quota? Am I getting more requests that I can?

  • Please check https://stackoverflow.com/questions/15122202/exceeded-quota-too-many-free-query-bytes-scanned-for-this-project-in-google-b – Lara19 Jul 07 '23 at 01:03

0 Answers0