|
Project Information
Members
|
SQLite Foreign Key Trigger Generator for SQLAlchemyBackgroundThis 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. External Links
Installation
Source CodeNow lives at bitbucket: https://bitbucket.org/rsyring/sqlitefktg4sa/ Stability
ExampleDownload 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
auto_assign(metadata)
#create tables and triggers
metadata.create_all()FeaturesCurrently supports:
|