the most straightforward way is to use an event: from sqlalchemy.schema import Table from sqlalchemy import event
@event.listens_for(Table, "column_reflect") def set_utc_date(inspector, table, column_info): if isinstance(column_info['type'], DateTime): column_info['type'] = UTCDateTime() On Jul 18, 2013, at 1:36 AM, Rit Li <heep...@gmail.com> wrote: > How can I make all datetime columns to use my UTCDateTime type by default? > > from sqlalchemy import types > from pytz import utc > > Base = declarative_base() > > class UTCDateTime(types.TypeDecorator): > > impl = types.DateTime > > def process_bind_param(self, value, engine): > if value is not None: > return value.astimezone(utc) > > def process_result_value(self, value, engine): > if value is not None: > return value.replace(tzinfo=utc) > > > class Game(Base): > __table__ = Table('games', metadata, autoload=True) > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.