Auto-update: Thu Jul 25 00:08:32 PDT 2024
This commit is contained in:
parent
cef2aaf910
commit
03ccf529c9
1 changed files with 7 additions and 6 deletions
|
@ -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:
|
||||||
INSERT INTO {table_name} ({', '.join(columns)})
|
await dest_conn.execute(f"""
|
||||||
VALUES ({', '.join(f'${i+1}' for i in range(len(columns)))})
|
INSERT INTO {table_name} ({', '.join(columns)})
|
||||||
ON CONFLICT ({', '.join(pk_cols)}) DO UPDATE SET
|
VALUES ({', '.join(f'${i+1}' for i in range(len(columns)))})
|
||||||
{', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col not in pk_cols)}
|
ON CONFLICT ({', '.join(pk_cols)}) DO UPDATE SET
|
||||||
""", [tuple(row[col] for col in columns) for row in rows])
|
{', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col not in pk_cols)}
|
||||||
|
""", *[row[col] for col in columns])
|
||||||
|
|
||||||
info(f"Completed processing table: {table_name}")
|
info(f"Completed processing table: {table_name}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue