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
- Monitors BigQuery dependency query results.
- Sends warning emails if the expected result is not met within a specified number of tries.
- Sends error emails if the maximum number of tries is exceeded without meeting the expected result.
- 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:
- dependency_query: SQL query to run on BigQuery to check for dependency.
- project: GCP project ID.
- expected_dependent_result: Expected result of the dependency query.
- number_of_tries: Number of times to retry the query.
- num_of_tries_before_warn_email: Number of tries before sending a warning email.
- time_interval: Time interval between retries (in seconds).
- warn_email_content: Content of the warning email.
- warn_email_subject: Subject of the warning email.
- email_address: Recipient email address.
- error_email_content: Content of the error email.
- error_email_subject: Subject of the error email.
- SMTP_SERVER: SMTP server address.
- SMTP_PORT: SMTP server port.
- SENDER_EMAIL: Sender email address.
- SMTP_USER: SMTP server user.
- SMTP_PASSWORD: SMTP server password.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Bigquery_dependency_email_trigger-0.1.tar.gz
.
File metadata
- Download URL: Bigquery_dependency_email_trigger-0.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd503e95c33b17029d76efc8e974ab30e4b740231c989909e3ee7a048c569e2 |
|
MD5 | 2ab4f8f7a6d29b03c47ab039a2967172 |
|
BLAKE2b-256 | bdc10c4cea1a4035a4362fdc0a970452d47e28790b01e5a7352b391ddd4bb48b |
File details
Details for the file Bigquery_dependency_email_trigger-0.1-py3-none-any.whl
.
File metadata
- Download URL: Bigquery_dependency_email_trigger-0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 441b24a8d06a53f8d3610ee54195c6756e1564a619ffa40a3bd04adca732035f |
|
MD5 | c7c4583c7a29e116769af64485f46233 |
|
BLAKE2b-256 | 091009698826da02a22ea7720d0faec48720021902bdc9aff4f1befe1f73e038 |