Skip to main content

No project description provided

Project description

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.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Bigquery_dependency_email_trigger-0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file Bigquery_dependency_email_trigger-0.1.tar.gz.

File metadata

File hashes

Hashes for Bigquery_dependency_email_trigger-0.1.tar.gz
Algorithm Hash digest
SHA256 afd503e95c33b17029d76efc8e974ab30e4b740231c989909e3ee7a048c569e2
MD5 2ab4f8f7a6d29b03c47ab039a2967172
BLAKE2b-256 bdc10c4cea1a4035a4362fdc0a970452d47e28790b01e5a7352b391ddd4bb48b

See more details on using hashes here.

File details

Details for the file Bigquery_dependency_email_trigger-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for Bigquery_dependency_email_trigger-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 441b24a8d06a53f8d3610ee54195c6756e1564a619ffa40a3bd04adca732035f
MD5 c7c4583c7a29e116769af64485f46233
BLAKE2b-256 091009698826da02a22ea7720d0faec48720021902bdc9aff4f1befe1f73e038

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page