Last active
February 2, 2021 19:13
-
-
Save fwarren/822d6c0984763e5e5fe07294e1dca65c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
employee_ids = [7, 25, 35, 18] | |
date_start = datetime.strptime('2021-01-15', '%Y-%m-%d') | |
date_finish = datetime.strptime('2021-01-31', '%Y-%m-%d') | |
def get_job_time_punches(cursor, employee_ids, date_start, date_end): | |
"""Get all punches fror all employees during the required date range.""" | |
SQL = """ | |
SELECT tp.inpunch_dt, tp.workingpunch_ts, tp.inout_id, job.job_id, | |
tp.task_id, tp.job_id, jobpunch_yn, job.jobname | |
FROM timeWorkingPunch tp | |
JOIN job ON tp.job_id = job.job_id | |
WHERE tp.employee_id IN (""" + ( "%s, " * len(employee_ids) )[:-2] + """) | |
AND tp.inpunch_dt BETWEEN %s AND %s | |
ORDER BY tp.inpunch_dt, tp.workingpunch_ts | |
""" | |
cursor.execute(SQL, (*employee_id, date_start, date_end)) | |
punches = cursor.fetchall() | |
return punches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment