Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
636 B
1
Indexable
Never
# Replace 'None' and 'NaT' with None in source_row
for column_name, source_val in source_row.items():
    if source_val == 'None' or source_val == 'NaT':
        source_row[column_name] = None

# Generate an INSERT query dynamically
insert_query = f"INSERT INTO {schema_ext}.{table_name} ("
insert_columns = []
insert_values = []

for column_name, source_val in source_row.items():
    insert_columns.append(column_name)
    insert_values.append(f"'{source_val}'" if source_val is not None else 'NULL')

insert_query += ", ".join(insert_columns)
insert_query += ") VALUES ("
insert_query += ", ".join(insert_values)
insert_query += ")"