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 = DDL('...')
> event.listen(
>     SomeName.__table__, 'after_create', trg.execute(bind=engine)
> )
> 
> But it excepts as the table doesn't exist. I assume this is a commit issue 
> maybe?
> What is the correct way to do something like this?

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




Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to