Skip to main content

Bigquery_dependency_email_trigger is a Python library that monitors the results of a BigQuery dependency query and sends email notifications based on the outcome. It is designed to help users automate and manage dependency checks and receive alerts via email.

Features

  1. Monitors BigQuery dependency query results.
  2. Sends warning emails if the expected result is not met within a specified number of tries.
  3. Sends error emails if the maximum number of tries is exceeded without meeting the expected result.
  4. Configurable retry intervals and email contents.

Installation

Install the library using pip:

pip install bigquery-dependency-email-trigger

Usage Here's an example of how to use the bigquery_dependency_email_trigger function:

import time
import pandas_gbq
from bigquery_dependency_email_trigger import bigquery_dependency_email_trigger

# Set up parameters
dependency_query = "SELECT COUNT(*) FROM `project.dataset.table` WHERE condition"
project = "your-gcp-project-id"
expected_dependent_result = "expected-result"
number_of_tries = 10
num_of_tries_before_warn_email = 5
time_interval = 60  # Time interval in seconds
warn_email_content = "Warning: Dependency check not met"
warn_email_subject = "Warning: Dependency Check"
email_address = "recipient@example.com"
error_email_content = "Error: Dependency check failed"
error_email_subject = "Error: Dependency Check Failed"
SMTP_SERVER = "smtp.example.com"
SMTP_PORT = 587
SENDER_EMAIL = "sender@example.com"
SMTP_USER = "smtp-user"
SMTP_PASSWORD = "smtp-password"

# Trigger dependency check
result = bigquery_dependency_email_trigger(
    dependency_query, project, expected_dependent_result,
    number_of_tries, num_of_tries_before_warn_email, time_interval,
    warn_email_content, warn_email_subject, email_address, error_email_content, error_email_subject,
    SMTP_SERVER, SMTP_PORT, SENDER_EMAIL, SMTP_USER, SMTP_PASSWORD
)

if result:
    print("Dependency met successfully.")
else:
    print("Dependency check failed.")

Parameters:

  1. dependency_query: SQL query to run on BigQuery to check for dependency.
  2. project: GCP project ID.
  3. expected_dependent_result: Expected result of the dependency query.
  4. number_of_tries: Number of times to retry the query.
  5. num_of_tries_before_warn_email: Number of tries before sending a warning email.
  6. time_interval: Time interval between retries (in seconds).
  7. warn_email_content: Content of the warning email.
  8. warn_email_subject: Subject of the warning email.
  9. email_address: Recipient email address.
  10. error_email_content: Content of the error email.
  11. error_email_subject: Subject of the error email.
  12. SMTP_SERVER: SMTP server address.
  13. SMTP_PORT: SMTP server port.
  14. SENDER_EMAIL: Sender email address.
  15. SMTP_USER: SMTP server user.
  16. SMTP_PASSWORD: SMTP server password.

Metadata

Release files for Bigquery-dependency-email-trigger 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Bigquery-dependency-email-trigger 0.1
File Size Uploaded
Bigquery_dependency_email_trigger-0.1.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Bigquery-dependency-email-trigger 0.1
File Interpreter ABI Platform
Bigquery_dependency_email_trigger-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / Bigquery_dependency_email_trigger-0.1.tar.gz

Download URL Bigquery_dependency_email_trigger-0.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
afd503e95c33b17029d76efc8e974ab30e4b740231c989909e3ee7a048c569e2
BLAKE2b-256 checksum
How to use checksums
bdc10c4cea1a4035a4362fdc0a970452d47e28790b01e5a7352b391ddd4bb48b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / Bigquery_dependency_email_trigger-0.1-py3-none-any.whl

Download URL Bigquery_dependency_email_trigger-0.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
441b24a8d06a53f8d3610ee54195c6756e1564a619ffa40a3bd04adca732035f
BLAKE2b-256 checksum
How to use checksums
091009698826da02a22ea7720d0faec48720021902bdc9aff4f1befe1f73e038
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page