16-06-2026 2nd commit
This commit is contained in:
+37
-1
@@ -19,7 +19,7 @@ def fetch_data(
|
||||
|
||||
mid_list = ",".join(str(mid) for mid in mids)
|
||||
|
||||
sql_file = Path("sql") / table_type / f"{table_name}.sql"
|
||||
sql_file = Path("sql") / f"{table_type}" / f"{table_name}.sql"
|
||||
|
||||
with open(sql_file, "r", encoding="utf-8") as f:
|
||||
sql_template = f.read()
|
||||
@@ -38,4 +38,40 @@ def fetch_data(
|
||||
|
||||
log.info(f"Fetched {len(df):,} rows from SQL Server")
|
||||
|
||||
return df
|
||||
|
||||
|
||||
|
||||
|
||||
def fetch_OQaD(
|
||||
engine: Engine,
|
||||
table_name: str,
|
||||
table_type: str,
|
||||
empids: list[int],
|
||||
run_date: date
|
||||
) -> pl.DataFrame:
|
||||
|
||||
empid_list = ",".join(str(empid) for empid in empids)
|
||||
|
||||
sql_file = Path("sql") / table_type / f"{table_name}.sql"
|
||||
|
||||
with open(sql_file, "r", encoding="utf-8") as f:
|
||||
sql_template = f.read()
|
||||
|
||||
sql = sql_template.format(
|
||||
empid_list=empid_list,
|
||||
run_date=run_date.strftime("%Y-%m-%d")
|
||||
)
|
||||
|
||||
log.info(f"Fetching data for {len(empids):,} EMPIDs")
|
||||
|
||||
log.info("Fetching OQaD data for run_date=%s", run_date)
|
||||
|
||||
df = pl.read_database(
|
||||
query=sql,
|
||||
connection=engine,
|
||||
)
|
||||
|
||||
log.info("Fetched %s rows", len(df))
|
||||
|
||||
return df
|
||||
Reference in New Issue
Block a user