title: Sqlite / SQLAlchemy: how to enforce Foreign Keys?
body: <p>The new version of SQLite has the ability to enforce Foreign Key constraints, but for the sake of backwards-compatibility, you have to turn it on for each database connection separately!</p>
  
  <pre><code>sqlite&gt; PRAGMA foreign_keys = ON;
  </code></pre>
  
  <p>I am using SQLAlchemy -- how can I make sure this always gets turned on?
  What I have tried is this:</p>
  
  <pre><code>engine = sqlalchemy.create_engine('sqlite:///:memory:', echo=True)
  engine.execute('pragma foreign_keys=on')
  </code></pre>
  
  <p>...but it is not working!...What am I missing?</p>
  
  <p><strong>EDIT:</strong>
  I think my real problem is that I have more than one version of SQLite installed, and Python is not using the latest one! </p>
  
  <pre><code>&gt;&gt;&gt; import sqlite3
  &gt;&gt;&gt; print sqlite3.sqlite_version
  3.3.4
  </code></pre>
  
  <p>But I just downloaded 3.6.23 and put the exe in my project directory!
  How can I figure out which .exe it's using, and change it?</p>