On Oct 7, 2013, at 10:26 PM, tiadobatima <gbara...@gmail.com> wrote:
> Hello there, > > I see that Column() has "default", "onupdate", and "server_default" to be > used when the value for that column is not present when inserting and > updating... > What would be the best way of rewriting a value that is present when > inserting or updating? if this is only Core, if you want to intercept statements and make modifications you'd use execution events, e.g. before_execute: http://docs.sqlalchemy.org/en/rel_0_8/core/events.html#sqlalchemy.events.ConnectionEvents.before_execute alternatively, you can use custom types to intercept values, e.g. TypeDecorator: http://docs.sqlalchemy.org/en/rel_0_8/core/types.html?highlight=typedecorator#sqlalchemy.types.TypeDecorator > Similarly, is there any easy way of rewriting the value of a column when > selecting? the only system that allows interception of result row values at the Core level is the typing system so you'd have to use TypeDecorator here. You can produce ad-hoc type changes using type_coerce (see the example for an ad-hoc rewrite of a string value to a GUID): http://docs.sqlalchemy.org/en/rel_0_8/core/sqlelement.html?highlight=type_coerce#sqlalchemy.sql.expression.type_coerce
signature.asc
Description: Message signed with OpenPGP using GPGMail