diff --git a/postgres/IngestDocument.py b/postgres/IngestDocument.py index 87f92bb..73333bf 100644 --- a/postgres/IngestDocument.py +++ b/postgres/IngestDocument.py @@ -69,8 +69,19 @@ def insert_document(conn, json_data): attributes.get("topics"), attributes.get("withdrawn"), attributes.get("zip"), + attributes.get("frDocNum"), + attributes.get("relationships").get("attachments").get("links").get("self"), + attributes.get("relationships").get("attachments").get("links").get("related"), + attributes.get("fileFormats"), + attributes.get("displayProperties"), ) + # attachments_self_link VARCHAR(2000), + # attachments_related_link VARCHAR(2000), + # file_formats JSONB, + # display_properties JSONB + + # Insert into the database try: with conn.cursor() as cursor: @@ -85,8 +96,9 @@ def insert_document(conn, json_data): submitter_org, phone, posted_date, postmark_date, reason_withdrawn, receive_date, reg_writer_instruction, restriction_reason, restriction_reason_type, state_province_region, subtype, - document_title, topics, is_withdrawn, postal_code - ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); + document_title, topics, is_withdrawn, postal_code, frdocnum, + attachments_self_link, attachments_related_link, file_formats, display_properties + ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); """ cursor.execute(insert_query, values) print(f"Document {document_id} inserted successfully.") @@ -94,7 +106,6 @@ def insert_document(conn, json_data): print(f"An error occurred: {e}") -# Main function to read JSON from file and insert into the database # Main function to read JSON from file and insert into the database def main(): if len(sys.argv) != 2: @@ -129,6 +140,5 @@ def main(): except Exception as e: print(f"An error occurred: {e}") - if __name__ == "__main__": main()