def _prep_datum(self, datum, dialect, col, needs_conversion):
        if datum is None or (needs_conversion and not str(datum).strip()):
            return 'NULL'
        pytype = self.columns[col]['pytype']

        if needs_conversion:
            if pytype == datetime.datetime:
                datum = dateutil.parser.parse(datum)
            elif pytype == bool:
                datum = th.coerce_to_specific(datum)
                if dialect.startswith('sqlite'):
                    datum = 1 if datum else 0
            else:
                datum = pytype(str(datum))

        if isinstance(datum, datetime.datetime) or isinstance(datum, datetime.date):
            if dialect in self._datetime_format:
                return datum.strftime(self._datetime_format[dialect])
            else:
                return "'%s'" % datum
        elif hasattr(datum, 'lower'):
            # simple SQL injection protection, sort of... ?
            return "'%s'" % datum.replace("'", "''")
        else:
            return datum
Puts a value in proper format for a SQL string
dataset/ETHPy150Open catherinedevlin/ddl-generator/ddlgenerator/ddlgenerator.py/Table._prep_datum