Untitled

 avatar
unknown
plain_text
a year ago
705 B
6
Indexable
if is_datetime(source_val):
    # Format datetime values using the appropriate function for the database type
    if db_type_ext == 'ORACLE':
        update_value = f"TO_DATE('{source_val}', 'YYYY-MM-DD HH24:MI:SS')"
    elif db_type_ext in ('MYSQL', 'MARIA'):
        # For MariaDB and MySQL, use STR_TO_DATE
        update_value = f"STR_TO_DATE('{source_val}', '%Y-%m-%d %H:%i:%s')"
    elif str(source_val) == 'NaT':
        # Replace 'NaT' with NULL without single quotes
        update_value = 'NULL'
    else:
        # Enclose other values in single quotes
        update_value = f"'{source_val}'"
else:
    update_value = f"'{source_val}'"  # Handle non-datetime columns (e.g., strings, numbers)

Editor is loading...