def value_to_db_decimal(self, value, max_digits, decimal_places):
        if value is None:
            return None
        if isinstance(value, decimal.Decimal):
            context = decimal.getcontext().copy()
            context.prec = max_digits
            return u"%.*f" % (decimal_places, value.quantize(decimal.Decimal(".1") ** decimal_places, context=context))
        else:
            return u"%.*f" % (decimal_places, value)
Transform a decimal.Decimal value to an object compatible with what is
dataset/ETHPy150Open avidal/django-pyodbc/sql_server/pyodbc/operations.py/DatabaseOperations.value_to_db_decimal