On Oct 15, 2013, at 9:19 PM, Jonathan <[email protected]> wrote: > Hello, > > I have a question about functions on columns in SQL Alchemy, and I can't seem > to find where in the Docs for release 0.8 that this is covered. > > I'm aware func.*() to run a function such as NOW() on either update or as a > default on the column, but I am wondering how to setup a function on > insert/update and another on select, such as using MySQL's INET6_ATON() and > INET6_NTOA() to convert IP Addresses to network byte order and back.
I think you're asking for how the function can be called transparently on the insert/select side, e.g. without having to specify it manually, this feature is relatively new and is available via the bind_expression() and column_expression() methods on types, see the example at http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#types-sql-value-processing which illustrates a very similar operation using PG's ST_GeomFromText and ST_AsText (you can pretty much swap in the INET6 functions here).
signature.asc
Description: Message signed with OpenPGP using GPGMail
