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

  • create_dataset(self, dataset_id, location)
  • create_table_from_df(self, table_id, df, partitioning, clustering, labels)
  • create_table_labels(self, cost_category, triggered_by, caller)
  • delete_dataset(self, dataset_id)
  • delete_table(self, table_id)
  • exists_table(self, table_id)
  • generate_bigquery_schema_from_df(self, df)
  • incremental_insert_with_deduplication(self, table_id, df, unique_key)
  • read_table_as_df(self, table_id)
  • sql2df(self, query)
  • upload_df_to_table(self, table_id, df)

GoogleBucketHelper

  • download_as_text(self, bucket_name, path)
  • exists_bucket(self, bucket_name)
  • upload_content(self, content, bucket_name, filename, content_type)

SecretManagerHelper

  • get_secret(self, project_id, secret_id)

Development

When new functions are added run uv run update_readme.py to update the README.md file.

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.5.tar.gz (16.0 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.5-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for google_cloud_helper-0.1.5.tar.gz
Algorithm Hash digest
SHA256 310964635f97faf9e5944d589354efa3a8fbfa8229ec3faf3adc2fa7573d66f6
MD5 4287cad663c71ac250b5b3a6bce32018
BLAKE2b-256 e9573f34543aee4f50f63459fcaedc1a1568f157d3bb6bd5df0413c87e423d12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for google_cloud_helper-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 54bd6e629b5e399f64414e7898285160283f177d820e01b72ab05809e692579c
MD5 275102a27df705cb77d58e4b1a00b8d7
BLAKE2b-256 b98e098c35c8676e24289131f4ce0f2e4690ed30814760e358104a9c2f2cdc67

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