Hi, I am working on creating a website using Flask. We are using the Flask-SQLAlchemy extension for ORM and SQLite for DB.
SQLIte doesn't have foreign key constraints enabled by default. They have to be enabled using the PRAGMA foreign_keys = ON; directive on each connection. I am not able to get flask-sqlalchemy to issue this directive on each connect. This is what I am doing in my "database.py" which is imported by all models subsequently. from flask_sqlalchemy import SQLAlchemy, event from mysite import app def enable_fkey(dbcon, con_rec): dbcon.execute('PRAGMA foreign_keys=ON;') db = SQLAlchemy(app) event.listen(db.get_engine(app), 'connect', enable_fkey) Can someone please help me with turning on SQLite Foreign Key constraints on each db connection ? Thanks -- Thank you Balachandran Sivakumar _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers