Updated at

This commit is contained in:
Your Name
2024-09-12 11:15:53 -06:00
parent d6eafb79f1
commit bf0874d0cc

12
app.py
View File

@@ -55,14 +55,15 @@ def insert_alumno_extraccion(datos_html: str, materias_html: str, username_integ
cur = conn.cursor() cur = conn.cursor()
insert_query = """ insert_query = """
INSERT INTO public.alumno_extraccion ("Usuario_claveULSA", datos_html, materias_html, historial_html, materias_actuales_html) INSERT INTO public.alumno_extraccion ("Usuario_claveULSA", datos_html, materias_html, historial_html, materias_actuales_html, updated_at)
VALUES (%s, TRIM(%s), TRIM(%s), TRIM(%s)::JSONB, TRIM(%s)) VALUES (%s, TRIM(%s), TRIM(%s), TRIM(%s)::JSONB, TRIM(%s), NOW())
ON CONFLICT ("Usuario_claveULSA") DO UPDATE ON CONFLICT ("Usuario_claveULSA") DO UPDATE
SET datos_html = EXCLUDED.datos_html, SET datos_html = EXCLUDED.datos_html,
materias_html = EXCLUDED.materias_html, materias_html = EXCLUDED.materias_html,
error_message = NULL, error_message = NULL,
registrado = DEFAULT, registrado = DEFAULT,
historial_html = EXCLUDED.historial_html; historial_html = EXCLUDED.historial_html,
updated_at = NOW();
""" """
cur.execute(insert_query, (username_integer, datos_html, materias_html, historial_html, materias_actuales_html)) cur.execute(insert_query, (username_integer, datos_html, materias_html, historial_html, materias_actuales_html))
@@ -84,11 +85,12 @@ def update_alumno_extraccion_error(username_integer: int, error: str):
cur = conn.cursor() cur = conn.cursor()
update_query = """ update_query = """
INSERT INTO public.alumno_extraccion ("Usuario_claveULSA", error_message) VALUES (%s, %s) INSERT INTO public.alumno_extraccion ("Usuario_claveULSA", error_message, updated_at) VALUES (%s, %s, NOW())
ON CONFLICT ("Usuario_claveULSA") DO UPDATE ON CONFLICT ("Usuario_claveULSA") DO UPDATE
SET error_message = EXCLUDED.error_message, SET error_message = EXCLUDED.error_message,
materias_html = DEFAULT, materias_html = DEFAULT,
registrado = DEFAULT; registrado = DEFAULT,
updated_at = NOW();
""" """
cur.execute(update_query, (username_integer, error[:255])) cur.execute(update_query, (username_integer, error[:255]))