Created
October 26, 2018 15:41
-
-
Save ansrivas/2b225054adb822c847703023ef670ae5 to your computer and use it in GitHub Desktop.
Sqlite foreign keys on with sqlalchemy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import event | |
from sqlalchemy.engine import Engine | |
@event.listens_for(Engine, "connect") | |
def set_sqlite_pragma(dbapi_connection, connection_record): | |
cursor = dbapi_connection.cursor() | |
cursor.execute("PRAGMA foreign_keys=ON") | |
cursor.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment