Database Trigger Creation

10 views
Skip to first unread message

JayFoolie

unread,
May 9, 2011, 10:48:23 PM5/9/11
to SQLElixir
Hi,

I'm trying to create triggers on a sqlite database.
I can create triggers using a database management tool like
SQLiteStudio. What I
want to do is implement the triggers in my python code.

I've tried using the "perform_ddl" method. I can do simple inserts of
data using the perform_ddl mehtod, but when sqlalchemy creates the
tables it doesn't seem to create my trigger. Here is whats my
statement looks like:

perform_ddl = ('after-create',
"CREATE TRIGGER
tgr_vendor_rma_item_UpdatePartStatusFailed AFTER INSERT ON
vendor_rma_item FOR EACH ROW BEGIN UPDATE Part SET status = 3 WHERE id
= ( SELECT part_id FROM vendor_rma_item WHERE part_id = NEW.part_id );
END;")

Am I missing something here? Is there possibly a better way to create
triggers than using the entity's perform_ddl method? Perhaps I need
to do this with sqlalchemy methods?

alex bodnaru

unread,
May 11, 2011, 2:03:44 AM5/11/11
to sqle...@googlegroups.com
cool you're using my extension ;) .

remove the first '=' please.

JayFoolie

unread,
May 11, 2011, 7:19:50 PM5/11/11
to SQLElixir
Haha thanks that worked! I must of had tunnel vision when reading the
api docs.

Thank you for creating this extension, its proving to be very useful.
Reply all
Reply to author
Forward
0 new messages