From ae80bf50dcf5157fcea470897a4dce5b2b4ca967 Mon Sep 17 00:00:00 2001 From: astanley Date: Mon, 17 Mar 2025 11:40:08 -0300 Subject: [PATCH] Loosened Content model --- ImportUtilities.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ImportUtilities.py b/ImportUtilities.py index edc362d..0d06a15 100644 --- a/ImportUtilities.py +++ b/ImportUtilities.py @@ -275,12 +275,15 @@ class ImportUtilities: result = cursor.execute(command).fetchone() return result['node_id'] if result is not None else '' - # Get node_id associated with pid. + # Get all pids with content model. def get_pids_by_content_model(self, table, content_model): - cursor = self.conn.cursor() - command = f"SELECT PID from {table} where CONTENT_MODEL like '%{content_model}%'" - result = cursor.execute(command).fetchone() - return result['node_id'] if result is not None else '' + cursor = self.conn.cursor() # Manually create a cursor + try: + command = f"SELECT PID FROM {table} WHERE CONTENT_MODEL LIKE ?" + cursor.execute(command, (f"%{content_model}%",)) + return [row[0] for row in cursor.fetchall()] # Extracts all PID values + finally: + cursor.close() # Ensures the cursor is always closed # Get key - value pairs from stored dublin core. def get_dc_values(self, pid): @@ -336,4 +339,5 @@ class ImportUtilities: if __name__ == '__main__': - MU = ImportUtilities('island_archives') \ No newline at end of file + MU = ImportUtilities('ivoices') + print(MU.get_pids_by_content_model('ivoices', 'audioCModel')) \ No newline at end of file