SQLiteFKTG4SA iconSQLiteFKTG4SA 0.1.1

SQLite Foreign Key Trigger Generator for SQLAlchemy
The SQLiteFKTG4SA project exists because SQLite parses fk column constraints but does not enforce them. You can read more about the problem and its solution if you are interested. The gist of it all is that triggers can be used in SQLite to enforce fk column constraints. I had previously created a project to do this in PHP but have recently been trying to move to Python. Since I am using SQLAlchemy, I really desired to generate the FKs automatically, and this project was born.


 * download the zip package
 * unzip contents to somewhere on your python path
 o /usr/lib/python2.5/site-packages or
 o c:Python25Libsite-packages
 * you should end up with something like c:Python25Libsite-packagessqlitefktg4sa...


 * currently only tested on windows. If you have problems on non-windows system, feel free to put in a bug report and I will fix quickly.
 * Even though we are only at 0.1, the code is very simple and there is a small test suite covering the obvious use cases. Therefore, it should be pretty stable and any errors should be obvious up front.


Download the package and look in the tests directory for a full example. Its really simple to use:

import * from sqlalchamy
from sqlitefktg4sa import SqliteFkTriggerGenerator, auto_assign

# define tables using Sqlalchemy

# set some tables manually to have FK generation happen
mytable1.append_ddl_listener('after-create', SqliteFkTriggerGenerator)
mytable2.append_ddl_listener('after-create', SqliteFkTriggerGenerator)

# OR, assign it automatically for all tables in your metadata

#create tables and triggers

Main features:

  • Currently supports:
  • insert
  • update
  • delete
  • delete cascade

last updated on:
December 15th, 2008, 15:51 GMT
developed by:
Randy Syring
license type:
BSD License 
ROOT \ Database \ Database APIs


In a hurry? Add it to your Download Basket!

user rating



Add your review!