show data that caused failure

This commit is contained in:
Mateusz Konieczny 2022-11-08 23:14:31 +01:00
parent 63ec84e9b2
commit ffe43dbd38

View File

@ -153,27 +153,31 @@ def filepath():
return os.path.dirname(os.path.realpath(__file__)) + os.sep + "data.json" return os.path.dirname(os.path.realpath(__file__)) + os.sep + "data.json"
def insert_entry(cursor, e): def insert_entry(cursor, e):
now = datetime.datetime.now() try:
application_url = None now = datetime.datetime.now()
if e["application_url"] != None: application_url = None
application_url = e["application_url"] if e["application_url"] != None:
cursor.execute('''INSERT INTO application_url = e["application_url"]
planning_data (planning_application_id, planning_application_link, description, registered_with_local_authority_date, days_since_registration_cached, decision_date, days_since_decision_date_cached, last_synced_date, status, status_before_aliasing, data_source, data_source_link, uprn) cursor.execute('''INSERT INTO
VALUES planning_data (planning_application_id, planning_application_link, description, registered_with_local_authority_date, days_since_registration_cached, decision_date, days_since_decision_date_cached, last_synced_date, status, status_before_aliasing, data_source, data_source_link, uprn)
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES
''', ( (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
e["application_id"], ''', (
application_url, e["description"], e["application_id"],
date_object_into_date_string(e["registered_with_local_authority_date"]), application_url, e["description"],
days_since(e["registered_with_local_authority_date"], now), date_object_into_date_string(e["registered_with_local_authority_date"]),
date_object_into_date_string(e["decision_date"]), days_since(e["registered_with_local_authority_date"], now),
days_since(e["decision_date"], now), date_object_into_date_string(e["decision_date"]),
date_object_into_date_string(e["last_synced_date"]), days_since(e["decision_date"], now),
e["status"], e["status_before_aliasing"], date_object_into_date_string(e["last_synced_date"]),
e["data_source"], e["status"], e["status_before_aliasing"],
e["data_source_link"], e["data_source"],
e["uprn"]) e["data_source_link"],
) e["uprn"])
)
except psycopg2.errors.Error as error:
show_dictionary(e)
raise error
def show_dictionary(data): def show_dictionary(data):
for key in data.keys(): for key in data.keys():