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)
  • update_table(self, df, table_id, 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.6.tar.gz (9.6 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.6-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for google_cloud_helper-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e5d77bc5f655021cb08b48e54cad3c63f1a961756e0012935e0883c29554e527
MD5 9031223d6267ba6c7f4c854f2cf45abf
BLAKE2b-256 77da87bc50dee9122ab8284081455a2d365a03dd37465674889ff3ce8a3c29f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for google_cloud_helper-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ba1b20a0d1a31d76dbc2f32f536b73a5a5af6ddbb3daeb89e421a2d3e815559f
MD5 722354d37f54694bc6d666ab2e1aca53
BLAKE2b-256 7188c8ae961059e3c4b760cec2c173dd4074056830c15c06eedb59a9c2d821ce

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