def quote_identifier(identifier, for_grants=False):
 if for_grants:
  return (('`' + identifier.replace('`', '``').replace('_', '\\_').replace('%', '\\%%')) + '`')
 else:
  return (('`' + identifier.replace('`', '``').replace('%', '%%')) + '`')

def quote_identifier ( identifier , for_grants = False ) : if for_grants : return ( ( '`' + identifier . replace ( '`' , '``' ) . replace ( '_' , '\\_' ) . replace ( '%' , '\\%%' ) ) + '`' ) else : return ( ( '`' + identifier . replace ( '`' , '``' ) . replace ( '%' , '%%' ) ) + '`' )
return an identifier name escaped for mysql this means surrounded by "" character and escaping this character inside .