Jason,
Thank you for the response. Using the method you suggest, am I
understanding correctly that fks_for_sqlite() would only be run when a
create() was processed for that table? Also, I am assuming I would
need to create a complimentary function for handling the 'after-drop'
event.
On Aug 22, 1:25 pm, jason kirtland <
j...@discorporate.us> wrote:
> DDL() has some simple templating capabilities that can help out a bit
> here, but I'd suggest taking the ForeignKey code Mike provided as a
> start and putting together an after-create listener using
> Table.append_ddl_listener directly:
>
>
http://www.sqlalchemy.org/docs/05/sqlalchemy_schema.html#docstrings_s...
>
> It would look something like:
>
> def fks_for_sqlite(event, table, bind):
> for c in table.c:
> for fk in c.foreign_keys:
> sql = your_code_to_make_trigger_for_fk(fk)
> bind.execute(sql)
>
> tbl.append_ddl_listener('after-create', fks_for_sqlite)
>
> Michael Bayer wrote:
> > you can build this functionality using the DDL() construct provided by
> > SQLAlchemy:
>
> >
http://www.sqlalchemy.org/docs/05/sqlalchemy_schema.html#docstrings_s...
>
> > the ForeignKey objects on the table can be pulled out using:
>
> > for c in table.c:
> > for fk in c.foreign_keys:
> > do_something_with_fk(fk)
>
> > On Aug 22, 2008, at 11:19 AM, Randy Syring wrote:
>
> >> I would like sqlalchemy to generate triggers on an SQLite database to
> >> enforce foreign key relationships. The method is documented here:
>
> >>
http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers
>
> >> and I have written a foreign key trigger generator here:
>
> >>
http://rcs-comp.com/site/index.php/view/Utilities-SQLite_foreign_key_...