code: def convert_dttm(
      cls,
      target_type: str,
      dttm: datetime,
      db_extra: Optional[dict[str, Any]] = None,
  ) -> Optional[str]:
      sqla_type = cls.get_sqla_column_type(target_type)
  
      if isinstance(sqla_type, types.Date):
          return f"STR_TO_DATE('{dttm.date().isoformat()}', '%Y-%m-%d')"
      if isinstance(sqla_type, types.DateTime):
          datetime_formatted = dttm.isoformat(
              sep=" ", timespec="microseconds"
          )
          return f"""STR_TO_DATE('{datetime_formatted}', '%Y-%m-%d %H:%i:%s.%f')"""
      return None
  
imports: import contextlib
  import re
  from datetime import datetime
  from decimal import Decimal
  from re import Pattern
  from typing import Any, Callable, Optional
  from urllib import parse
  from flask_babel import gettext
  from sqlalchemy import types
  from sqlalchemy.dialects.mysql import BIT, DECIMAL, DOUBLE, FLOAT, INTEGER, LONGTEXT, MEDIUMINT, MEDIUMTEXT, TINYINT, TINYTEXT
  from sqlalchemy.engine.url import URL
  from superset.constants import TimeGrain
  from superset.db_engine_specs.base import BaseEngineSpec, BasicParametersMixin
  from superset.errors import SupersetErrorType
  from superset.models.sql_lab import Query
  from superset.utils.core import GenericDataType
label_desc: Use image node_id 1 for calling the MySQLEngineSpec obj's underlying member method code with example usage: obj.convert_dttm(cls, target_type, dttm, db_extra) and returns: None, str, dttm, str, str, datetime_formatted, str