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.8.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.8-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for google_cloud_helper-0.1.8.tar.gz
Algorithm Hash digest
SHA256 952022f684933b99ac360e1f73a004f8c2b7fe7639ef66d0ea2002623ef3b490
MD5 dbc772a1af5435b7e14ce4c792eb6a3e
BLAKE2b-256 7533b3b012f82fdf04d2163fa5c423dfd57a5451625f9d7222185842248f4284

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for google_cloud_helper-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d768e4950bbf3e12eea61ea59327d1cac84fc982f7b993bd78fa62021bf2090a
MD5 0379a2d435efa8477a23e68e3eecd925
BLAKE2b-256 fd2b15fa185fc11e600dad466431187f9bad84829e1e26dd84c154961d3cd910

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