Files
PMT-Rooster-Fetcher/main.py
2026-03-19 16:02:53 +01:00

32 lines
673 B
Python

from PMT import PMT
from DB import Database
from dotenv import load_dotenv
from time import sleep
import os
def main():
# Load the environment
load_dotenv(override=True)
# Set up database, webserver and PMT connection
db = Database()
pmt = PMT()
# fetch PMT shifts
pmt.login()
days_ahead = int(os.environ.get("DAYS_TO_FETCH"))
shifts = pmt.get_shifts(days_ahead)
db.delete_future_shifts() # delete all future shifts before importing, to make sure if a shift is removed, it actually gets removed here too.
# Insert the new shifts into the database
db.insert_shifts(shifts)
if __name__ == "__main__":
main()