def iso_string_to_sql_utcdatetime_pythonformat_sqlite(x: str) -> str:
    """
    Provides SQLite SQL to convert a column to a ``DATETIME`` in UTC, in a
    string format that matches a common Python format. The argument ``x`` is
    the SQL expression to be converted (such as a column name).

    Output like

    .. code-block:: none

        2015-11-14 18:52:47
        2015-11-14 18:52:47.247000

    i.e.

    - gets rid of trailing ``.000`` for zero milliseconds, appends
      trailing ``000`` for everything else,
    - ... thus matching the output of Python's ``str(x)`` where ``x`` is a
      ``datetime``.
    - ... thus matching the RHS of a Django default ``datetime`` comparison.
    """
    return f"""
        CASE SUBSTR(STRFTIME('%f', {x}), 4, 3)
        WHEN '000' THEN STRFTIME('%Y-%m-%d %H:%M:%S', {x})
        ELSE STRFTIME('%Y-%m-%d %H:%M:%f', {x}) || '000'
        END
    """