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.exists_table("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.exists_bucket("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)
  • list_all_files_in_bucket(self, bucket_name, folder_name, suffix)
  • 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.9.tar.gz (10.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.9-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: google_cloud_helper-0.1.9.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for google_cloud_helper-0.1.9.tar.gz
Algorithm Hash digest
SHA256 cc0bc845d46ca7a6ac9d89de06669c474a0f1744d09b59e2e6d4bb4bb8c60d72
MD5 551762c585a6e91e0c897d1a3d93eba5
BLAKE2b-256 12a114ef22871eb63378efadcd8bd28009cecdf8230738f7d74068568250628d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: google_cloud_helper-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for google_cloud_helper-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b71d1f9db707e7a74dd087409b269b486adcdd1c700f599df3c27c86ead064ed
MD5 1904543ef2858c28434be918597d95f8
BLAKE2b-256 7fae689449ab92446e68db2fcb5fad5dc17a06f4aeca3ef8889a6723015be276

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