ive completed the "onupdate" option for Column objects, so now you can do:

        Column("mycol", String(30), onupdate=func.ts_updater())

and the SQL function ts_updater() will be pre-executed, its value placed within the bind parameters for any update statement on the table that does not have the column present or has a parameter value of None. So to have pre-execution of functions for both INSERT and UPDATE:

Column('mycol', String(30), default=func.my_insert_func(), onupdate=func.my_update_func())

to just use Python functions instead of SQL functions:

Column('mycol', String(30), default=my_python_func, onupdate=my_python_func)

note that these defaults are "pre-insert" and "pre-update" and only correspond to a parameter value of None, so theyre not as flexible as a real SQL trigger, which could conceivable fire off any time, pre- or post- exec, etc.


On Mar 3, 2006, at 3:11 PM, Alan Franzoni wrote:

Il Fri, 3 Mar 2006 13:29:52 -0500, Michael Bayer ha scritto:

cant these be triggers directly on the table ?

Well, I just posted the trigger functions, which are required by
postgresql. Those are reusable, database-wide functions; then the triggers are set, which are directly attached on the table; each table requires its
own triggers:

CREATE TRIGGER updatecolumn BEFORE UPDATE
        ON tablename FOR EACH ROW
        EXECUTE PROCEDURE public.ts_updater();

CREATE TRIGGER log_deleted
        AFTER DELETE
        ON tablename
        FOR EACH ROW
        EXECUTE PROCEDURE public.trashlogger();

if not, Id just attach a ColumnDefault to the columns in question,
which call the appropriate SQL function, and wait for me to fix the
ticket that allows ColumnDefaults to be used upon update as well as
insert.

That looks promising. I won't waste your time anymore, then :P

--
Alan Franzoni <[EMAIL PROTECTED]>
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel? cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to