The BigQuery Storage API lets a Python application read BigQuery data into a Pandas dataframe faster than using the BigQuery API alone. In a Streamlit dashboard, it works alongside BigQuery: BigQuery runs the query, while the Storage API helps convert the returned data for dataframe use. section 7.7.2 section 7.7.3
A practical setup follows these steps:
- Enable both the BigQuery API and BigQuery Storage API in the Google Cloud project. section 7.7.2
- Install google-cloud-bigquery, google-cloud-bigquery-storage, and db-dtypes. section 7.7.3
- Authenticate with service-account credentials stored in Streamlit secrets, then reuse the BigQuery client credentials for the Storage API client. section 7.7.2
Loading dashboard data
A modular data_loader.py can create a BigQuery client, initialize BigQueryReadClient with the same credentials, run SELECT * against a project.dataset.table reference, and return result.to_dataframe(bqstorage_client=storage_client). Updating only load_data lets the rest of the dashboard continue working while its data source changes from a static CSV file to BigQuery. section 7.7.3
