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, specific_types)
  • 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, specific_types)
  • incremental_insert_with_deduplication(self, table_id, df, id_cols)
  • read_table_as_df(self, table_id)
  • sql2df(self, query)
  • update_table(self, table_id, df, id_cols)
  • 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.7.tar.gz (9.8 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.7-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for google_cloud_helper-0.1.7.tar.gz
Algorithm Hash digest
SHA256 16c8b1625dc0a37c59a24c49a32b1ba08ef6d076ef0e3fd3b3ad4f20fa571004
MD5 f1d2dfccc55b91ee4ed9dfe044366089
BLAKE2b-256 41eb54a04d6f8b718e4ec9f8712f66cefa1ed46dee34a1bdaf7257053184d464

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for google_cloud_helper-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d51332c4085022710bb6fe0450f91ce8ee4ea528ff14a911e9b4e38aa22cf363
MD5 2ba7911d4d91b6fefb93fae5278e09d4
BLAKE2b-256 362eaff5818db1a28a11a1dde91407a7f730a723fb72b2334ba134f001facdb1

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