My employers have a custom Python type (derived from datetime) for
dealing with dates and datetimes.Let's call it 'BananaDate'. They
would like BananaDate be used by SQL Alchemy. The standard way of
doing this appears to be with a TypeDecorator:
class BananaDate(types.TypeDecorator):
from banana.date import Date
impl = types.Date
def process_result_value(self, value, dialect):
return banana(value)
I understand that the Column definitions would change from:
Column('first_reset_dt', DateTime, nullable=True)
to
Column('first_reset_dt', BananaDate, nullable=True)
These seems to imply that I have to explicitly change the models (and
I would prefer not to do that)
Is there some neat 'hook-based' approach that would allow me to leave
the metadata models intact and yet work with BananaDates? Would it be
very rude to monkey-patch the relevent base types in sqlalchemy.types
with new definition of process_result_value?
pjjH
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---