41 lines
853 B
Python
41 lines
853 B
Python
import yaml
|
|
from datetime import date, timedelta
|
|
|
|
mids_list=[1,3]
|
|
|
|
run_date=date.today()
|
|
conditions = {
|
|
"mids": f"MID IN ({','.join(map(str, mids_list))})",
|
|
|
|
"j_plan": (
|
|
f"MONTH(VisitDate) = {run_date.month} "
|
|
f"AND YEAR(VisitDate) = {run_date.year}"
|
|
),
|
|
|
|
"mapping": (
|
|
f"CAST(Z.FromDate AS DATE) <= '{run_date}' "
|
|
f"AND CAST(Z.ToDate AS DATE) >= '{run_date}'"
|
|
),
|
|
|
|
"web": (
|
|
f"CAST(login_date AS DATE) = '{run_date}'"
|
|
),
|
|
|
|
"none": None,
|
|
}
|
|
|
|
|
|
with open("tables.yml", "r") as file:
|
|
config = yaml.safe_load(file)
|
|
|
|
for table in config["tables"]:
|
|
|
|
table_name=table["name"]
|
|
table_type=table["type"]
|
|
operation=table["operation"]
|
|
condition=table["condition"]
|
|
c = conditions[condition]
|
|
print(table_name)
|
|
print(table_type)
|
|
print(operation)
|
|
print(c) |