Untitled

 avatar
unknown
plain_text
2 years ago
636 B
4
Indexable
# 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 += ")"
Editor is loading...