Michael Bayer wrote:
> there is a capability within the dialect to determine the "quotability"
> of SQL identifiers, via the "preparer()" function. check out its
> implementation in ansisql.py. i can add the"preparer()" function and a
> base class for the preparer itself to the base Dialect class which will
> make this capability more public.
The preparer contains a method __generic_obj_format(self, obj, ident)
which does what I have in mind. But for one, it's private, and second,
it takes an obj parameter which I don't need. I want to process only the
identifiert (e.g. for a user, who has no representation in SA anyway),
like that:
def _format_identifier(self, ident):
if self.requires_quotes(ident, ident == ident.lower()):
return self._quote_identifier(ident)
else:
return ident
Then I could insert user names like that:
'alter user %s set password=:pwd' % prep._format_identifier(username)
Alternatively, I could simply _always_ quote identifiers:
'alter user %s set password=:pwd' % prep._quote_identifier(username)
_That_ method is actually so simple that I could do it myself:
'alter user "%s" set password=:pwd' % username.replace('"', '""')
Anyway, maybe you can consider adding the _format_identifier method.
-- Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~----------~----~----~----~------~----~------~--~---