Beispiel #1
0
    def _DATETIME_to_python(self, value, dsc=None):
        """Connector/Python always returns naive datetime.datetime

        Connector/Python always returns naive timestamps since MySQL has
        no time zone support. Since Django needs non-naive, we need to add
        the UTC time zone.

        Returns datetime.datetime()
        """
        if not value:
            return None
        dt = MySQLConverter._DATETIME_to_python(self, value)
        if dt is None:
            return None
        if settings.USE_TZ and timezone.is_naive(dt):
            dt = dt.replace(tzinfo=timezone.utc)
        return dt
Beispiel #2
0
 def quote_value(self, value):
     # Inner import to allow module to fail to load gracefully
     from PyMysqlPool.mysql.connector.conversion import MySQLConverter
     return MySQLConverter.quote(MySQLConverter.escape(value))