Auto-update: Thu Jul 25 00:08:32 PDT 2024

This commit is contained in:
sanj 2024-07-25 00:08:32 -07:00
parent cef2aaf910
commit 03ccf529c9

View file

@ -375,12 +375,13 @@ class APIConfig(BaseModel):
if rows: if rows:
columns = rows[0].keys() columns = rows[0].keys()
# Upsert records to the destination table # Upsert records to the destination table
await dest_conn.executemany(f""" for row in rows:
await dest_conn.execute(f"""
INSERT INTO {table_name} ({', '.join(columns)}) INSERT INTO {table_name} ({', '.join(columns)})
VALUES ({', '.join(f'${i+1}' for i in range(len(columns)))}) VALUES ({', '.join(f'${i+1}' for i in range(len(columns)))})
ON CONFLICT ({', '.join(pk_cols)}) DO UPDATE SET ON CONFLICT ({', '.join(pk_cols)}) DO UPDATE SET
{', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col not in pk_cols)} {', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col not in pk_cols)}
""", [tuple(row[col] for col in columns) for row in rows]) """, *[row[col] for col in columns])
info(f"Completed processing table: {table_name}") info(f"Completed processing table: {table_name}")