(ident, ansi_quotes, should_quote)
return join_field(esc(f) for f in split_field(ident))
Escape identifiers.

    ANSI uses single quotes, but many databases use back quotes.
Escape identifiers.
Escape identifiers .
def escape(ident, ansi_quotes, should_quote):
    """
    Escape identifiers.

    ANSI uses single quotes, but many databases use back quotes.

    """
    def esc(identifier):
        if not should_quote(identifier):
            return identifier

        quote = '"' if ansi_quotes else '`'
        identifier = identifier.replace(quote, 2*quote)
        return '{0}{1}{2}'.format(quote, identifier, quote)
    return join_field(esc(f) for f in split_field(ident))
def escape ( ident , ansi_quotes , should_quote ) : def esc ( identifier ) : if not should_quote ( identifier ) : return identifier quote = '"' if ansi_quotes else '`' identifier = identifier . replace ( quote , 2 * quote ) return '{0}{1}{2}' . format ( quote , identifier , quote ) return join_field ( esc ( f ) for f in split_field ( ident ) )