Skip to content

Commit

Permalink
MDL: Upated log format
Browse files Browse the repository at this point in the history
  • Loading branch information
TheurgicDuke771 committed Jul 15, 2023
1 parent a86f629 commit ea1d2fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions python_scripts/mdl_psql.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_synopsis(item_url: str) -> str:
else:
raise Exception(f"URL: {details_url}. Response: {response_raw.text}")
except Exception as e:
print(f"{ETL_TIME} ERROR: {str(e)}")
print(f"{ETL_TIME} WARNING: {str(e)}")
return "No synopsis available"


Expand Down Expand Up @@ -120,6 +120,7 @@ def inset_into_db(content_list: list) -> int:
cur.execute(insert_query)
conn.commit()
affected_rec_cnt += 1

else:
existing_synopsis = result["synopsis"].values[0]
if (
Expand Down Expand Up @@ -157,6 +158,7 @@ def inset_into_db(content_list: list) -> int:
cur.execute(update_query)
conn.commit()
affected_rec_cnt += 1

else:
update_query = f"""
UPDATE {table_name} SET
Expand All @@ -183,7 +185,7 @@ def inset_into_db(content_list: list) -> int:
conn.commit()
affected_rec_cnt += 1
except Exception as e:
print(f"{ETL_TIME} ERROR: {str(e)}")
print(f"{ETL_TIME} WARNING: {str(e)}")

return affected_rec_cnt

Expand Down
15 changes: 9 additions & 6 deletions python_scripts/mdl_psql_current.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@


ETL_TIME = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
mdl_list = get_seasonal_data()
if len(mdl_list) > 0:
rec_count = inset_into_db(mdl_list)
print(f'{ETL_TIME} INFO: {rec_count} records inserted at {ETL_TIME}.')
else:
print(f"{ETL_TIME} INFO: No records to insert")
try:
mdl_list = get_seasonal_data()
if len(mdl_list) > 0:
rec_count = inset_into_db(mdl_list)
print(f"{ETL_TIME} INFO: {rec_count} records inserted.")
else:
print(f"{ETL_TIME} INFO: No records to insert")
except Exception as e:
print(f"{ETL_TIME} ERROR: {str(e)}")
2 changes: 1 addition & 1 deletion python_scripts/mdl_psql_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@

if len(mdl_list) > 0:
rec_count = inset_into_db(mdl_list)
print(f'{ETL_TIME} INFO: {rec_count} records inserted at {ETL_TIME}.')
print(f"{ETL_TIME} INFO: {rec_count} records inserted.")
else:
print(f"{ETL_TIME} INFO: No records to insert")

0 comments on commit ea1d2fe

Please sign in to comment.