cant these be triggers directly on the table ?

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.

On Mar 3, 2006, at 11:16 AM, Alan Franzoni wrote:

Il Wed, 1 Mar 2006 11:19:47 -0500, Michael Bayer ha scritto:

[cut]

I think I wasn't able to explain my point properly. I'm using some database triggers on pgsql, the trigger functions (kind of python-psycopg quoted,
since they're taken from a cursor.execute() statement) are:

    CREATE OR REPLACE FUNCTION trashlogger() \
    RETURNS \"trigger\" AS \
    $BODY$ \
    begin \
    INSERT INTO tobetrashed VALUES ( DEFAULT,
TG_RELNAME,OLD.id,CURRENT_TIMESTAMP ); \
    RETURN NULL; \
    end;$BODY$ \
    LANGUAGE \'plpgsql\' VOLATILE; \
    ALTER FUNCTION trashlogger() OWNER TO postgres;

    CREATE OR REPLACE FUNCTION ts_updater() \
    RETURNS \"trigger\" AS \
    $BODY$ \
    begin \
      new.last_upd = CURRENT_TIMESTAMP; \
      return new; \
    end; \
    $BODY$ \
    LANGUAGE \'plpgsql\' VOLATILE;')

If an update occurs, the last_upd column in the record gets updated. If a
delete occurs, a new record is inserted in the 'tobetrashed' table,
containing the name of the table from which the record was trashed and the
id of the trashed record.

All of this is used to manage a simple asynchronous multimaster replication
system on some low-traffic databases.

in sqlalchemy, it would be great to have the opportunity to modify a
statement on-the-fly when an UPDATE occurs (just like the ts_updater()
function) or to attach a new statement (to be executed before the deletion)
when a DELETE occurs. Sqlalchemy already figures out when an update is
really needed, so there would be no unnecessary commits.

I realize this could be complex, or simply beyond the scope of sqlalchemy.
I would try implenting it myself, but I'm still studying sqlalchemy's
internals and I haven't grasped everything yet, so I need a 'clue' on what
way should I take first.

--
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