Untitled
unknown
plain_text
a year ago
746 B
3
Indexable
# 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(): if source_val is not None and isinstance(source_val, str) and ' ' in source_val: # Check if the value is a string and contains a space (indicating a datetime string) formatted_datetime = f"TO_DATE('{source_val}', 'YYYY-MM-DD HH24:MI:SS')" # Format as TO_DATE insert_values.append(formatted_datetime) else: 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...