'Return a string of the query last executed by the given cursor, with
placeholders replaced with actual values.
`sql` is the raw query containing placeholders and `params` is the
sequence of parameters. These are used by default, but this method
exists for database backends to provide a better implementation
according to their own quoting schemes.'

def last_executed_query(self, cursor, sql, params):

    def to_string(s):
        return force_text(s, strings_only=True, errors='replace')
    if isinstance(params, (list, tuple)):
        u_params = tuple((to_string(val) for val in params))
    elif (params is None):
        u_params = ()
    else:
        u_params = {to_string(k): to_string(v) for (k, v) in params.items()}
    return ('QUERY    =    %r    -    PARAMS    =    %r' % (sql, u_params))
