the most classical way to do this is via column_property():
class Host(Base):
__tablename__ = 'hosts'
id = Column(Integer, primary_key=True)
_mac = Column('mac', Integer)
mac = column_property(func.hex(_mac))
the autoload here makes things a little more strange, we're defining
"mac" as a Column even though it is reflected just so that we have
something to refer to.
If you don't define it, then you need to add the property after the
Host class exists, so that the Table is there and has been autoloaded
and you'll be able to get to Host.mac.
It might also be possible to use autoload, not define "mac" as a column
up front, and use @declared attr (see
http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/declarative/mixins.html#mixing-in-deferred-column-property-and-other-mapperproperty-classes)
in order to refer to the column after the autoload, but I'm not sure if
the order of operations works out for that to work.
>
> Thanks in advance,
>
> Regards
> Balaji
>
>
>
> --
> 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+...@googlegroups.com
> <mailto:
sqlalchemy+...@googlegroups.com>.
> To post to this group, send email to
sqlal...@googlegroups.com
> <mailto:
sqlal...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/sqlalchemy.
> For more options, visit
https://groups.google.com/d/optout.