Skip to main content

Add your description here

Project description

google-cloud-helper

This repository contains common functions for easy access to Google Cloud Infrastructure, such as Big Query or Google buckets.

Example Usage

from google_cloud_helper.BigQueryHelper import BigQueryHelper
from google_cloud_helper.GoogleBucketHelper import GoogleBucketHelper
from google_cloud_helper.SecretManagerHelper import SecretManagerHelper

# BigQuery
bq_helper = BigQueryHelper("your-gcp-project-id")
exists = bq_helper.table_exists("your-gcp-project-id.dataset.table")
print(f"Table exists: {exists}")

# Google Cloud Storage
bucket_helper = GoogleBucketHelper("your-gcp-project-id")
bucket_exists = bucket_helper.bucket_exists("your-bucket-name")
print(f"Bucket exists: {bucket_exists}")

# Secret Manager
secret_helper = SecretManagerHelper()
my_secret = secret_helper.get_secret("your-gcp-project-id", "your-secret-id")
print("Successfully retrieved secret!")

Available Functions

BigQueryHelper

Function Description
table_exists(table_id) Checks if a specific BigQuery table exists.
create_dataset(dataset_id) Creates a new BigQuery dataset if it doesn't already exist.
delete_table(table_id) Deletes a BigQuery table.
create_table_from_df(...) Creates and populates a table from a pandas DataFrame, with options for partitioning and clustering.
upload_df_to_table(table_id, df) Appends a pandas DataFrame to an existing BigQuery table.
incremental_insert_with_deduplication(...) Inserts new rows from a DataFrame, avoiding duplicates based on a unique key.
generate_bigquery_schema(df) Infers a BigQuery schema from a pandas DataFrame.

GoogleBucketHelper

Function Description
download_as_text(bucket, path) Downloads a file from a Google Cloud Storage bucket as text.
bucket_exists(bucket_name) Checks if a specific Google Cloud Storage bucket exists.

SecretManagerHelper

Function Description
get_secret(project_id, secret_id) Retrieves the latest version of a secret from Secret Manager.

Testing

To run the tests, execute the following command:

uv run pytest

Build and Publish

To build and publish the package to PyPI, execute the following command:

uv build
uv publish --token <pypi-token>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_cloud_helper-0.1.4.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_cloud_helper-0.1.4-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file google_cloud_helper-0.1.4.tar.gz.

File metadata

  • Download URL: google_cloud_helper-0.1.4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for google_cloud_helper-0.1.4.tar.gz
Algorithm Hash digest
SHA256 53703518bc1539e5928ce0199cae2a8976a1bbb6ba093e707c39144d8db79ab5
MD5 507010febf8099ba48adde4b9367e382
BLAKE2b-256 07b9dd3cbfafa806a605f69677cbc89e39e6f640316b9c6bd5afaa5bea500c88

See more details on using hashes here.

File details

Details for the file google_cloud_helper-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for google_cloud_helper-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 477e7db68a4090ae30da4fabde4e5e68846c7424d381a61541cadf6cf2f25750
MD5 0db9bf01d3a43e03d4867c6c9666ec70
BLAKE2b-256 e67c77a88593ad44f18daca36eb175eb445363e86933acc82831f06bdbf21b87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page