From 8f38810626f6f4c9fc287553e1ad091d68f4d192 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:59:33 -0700 Subject: [PATCH] Auto-update: Tue Jul 30 16:59:33 PDT 2024 --- sijapi/classes.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sijapi/classes.py b/sijapi/classes.py index 1bf0d43..4d354ac 100644 --- a/sijapi/classes.py +++ b/sijapi/classes.py @@ -653,6 +653,7 @@ class APIConfig(BaseModel): debug(f"Number of changes for {table_name}: {len(changes)}") if changes: + debug(f"Sample change for {table_name}: {changes[0]}") changes_count = await self.apply_batch_changes(dest_conn, table_name, changes, has_primary_key) total_changes += changes_count @@ -720,12 +721,16 @@ class APIConfig(BaseModel): # Prepare the statement stmt = await conn.prepare(insert_query) - # Convert list of dicts to list of tuples - values_list = [tuple(change[col] for col in columns) for change in changes] - - # Use executemany for batch insert - result = await stmt.executemany(values_list) - affected_rows = len(values_list) # Assume all rows were affected + affected_rows = 0 + for change in changes: + try: + values = [change[col] for col in columns] + result = await stmt.fetchval(*values) + affected_rows += 1 + except Exception as e: + err(f"Error inserting row into {table_name}: {str(e)}") + err(f"Row data: {change}") + # Continue with the next row return affected_rows @@ -736,6 +741,7 @@ class APIConfig(BaseModel): + async def sync_spatial_ref_sys(self, source_conn, dest_conn): try: # Get all entries from the source