def subst_quoted_strings(sql, params):
    """Reverse operation to mark_quoted_strings - substitutes '@' by params.
    """
    parts = sql.split('@')
    params_dont_match = (
        "number of parameters doesn' match the transformed query")
    assert len(parts) == len(params) + 1, params_dont_match
    out = []
    for i, param in enumerate(params):
        out.append(parts[i])
        out.append("'%s'" % param.replace('\\', '\\\\').replace("'", "\\'"))
    out.append(parts[-1])
    return ''.join(out)
