BigQuery Helper
BigQuery Helper is a Python package that simplifies working with Google BigQuery. It provides an easy-to-use interface for common BigQuery operations such as executing queries, inserting rows, and working with DataFrames.
Installation
You can install BigQuery Helper using pip:
pip install bigquery-helper
Usage
To use BigQuery Helper, you'll need a Google Cloud project and credentials. Here's how to get started:
-
Set up a Google Cloud project and enable the BigQuery API.
-
Create a service account and download the JSON key file.
-
Set the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable to the path of your JSON key file:export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/keyfile.json"Alternatively, you can pass the credentials directly when initializing the BigQueryHelper.
Here's a quick example of how to use BigQuery Helper:
from bigquery_helper import BigQueryHelper
# Initialize BigQueryHelper
bq_helper = BigQueryHelper(project_id="your-project-id", credentials="/path/to/your/keyfile.json")
# Execute a query and get results as a DataFrame
query = "SELECT * FROM `your_dataset.your_table` LIMIT 10"
df = bq_helper.query_to_dataframe(query)
print(df)
# Insert rows into a table
rows_to_insert = [
{"column1": "value1", "column2": 123},
{"column1": "value2", "column2": 456}
]
bq_helper.insert_rows("your_dataset.your_table", rows_to_insert)
# Upload a DataFrame to BigQuery
import pandas as pd
df_to_upload = pd.DataFrame({"column1": ["a", "b"], "column2": [1, 2]})
bq_helper.dataframe_to_table(df_to_upload, "your_dataset.new_table", if_exists="replace")
# Update a column in a table
bq_helper.update_column("your_dataset.your_table", "id_column", "status_column", [1, 2, 3])
# Get schema of a table
schema = bq_helper.get_schema("your_dataset.your_table")
print(schema)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Metadata
Release files for bigquery-helper 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bigquery-helper-0.1.0.tar.gz | 6.1 kB | Without provenance | Details for bigquery-helper-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bigquery_helper-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bigquery_helper-0.1.0-py3-none-any.whl |
Total release size: 11.8 kB
Release files / bigquery-helper-0.1.0.tar.gz
| Download URL | bigquery-helper-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45826157decb7bfe51bc648c4bf8decf8aa142dba0b842f6b12bbc1b609ccd43
|
|
BLAKE2b-256 checksum How to use checksums |
ac2bf5394df8d2b4bbb2b892171067ed44e0e34e3232fd3718ef1d132713d0bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.4
|
Release files / bigquery_helper-0.1.0-py3-none-any.whl
| Download URL | bigquery_helper-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d0257b9686f06701a8b6efa557a54d37892afc56648ce86110075f0ed8d13cc
|
|
BLAKE2b-256 checksum How to use checksums |
43c60db922bb8420eb7b3e0a1dc5caba8a7e19aea1d0a439ebd9e33116be7e91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.4
|
Security for bigquery-helper 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.