[sqlalchemy] Adding a trigger

2013-10-17 Thread Joseph Casale
I have a module I import which has some table defs and global sessionmaker() instance. If the module is ran directly, it executes a create_all() to build a new db. I am trying to add a trigger DDL event listener: trg = DDL('...') event.listen( SomeName.__table__, 'after_create',

Re: [sqlalchemy] Adding a trigger

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 1:13 PM, Joseph Casale jcas...@gmail.com wrote: I have a module I import which has some table defs and global sessionmaker() instance. If the module is ran directly, it executes a create_all() to build a new db. I am trying to add a trigger DDL event listener: trg =

Re: [sqlalchemy] Adding a trigger

2013-10-17 Thread Joseph Casale
you need to pass a Python callable function (def or lambda, typically) to event.listen, which it will call when the event occurs. right now you're just running the execute() before the listen() is even called: event.listen(table, after_create, lambda *args: trg.execute(bind=engine))