title: SQLite3 "forgets" to use foreign keys
body: <p>I'm using Ruby with SQLite3 and my attempts to use foreign keys in Sqlite3 were unfortunately not successful. According to <code>sqlite3 --version</code>, version 3.7.13 is installed. As far as I know, Sqlite3 supports foreign keys since version 3.6.x.</p>
  
  <p>I know that foreign keys are deactivated by default and have to be activated with <code>PRAGMA foreign_keys = ON;</code>. In my Ruby db-create-script, I'm doing something like this:</p>
  
  <pre><code>sql = &lt;&lt;-SQL
    PRAGMA foreign_keys = ON;
    CREATE TABLE apps (
      id ....
    );
    CREATE TABLE requests (
      ...
      app_id INTEGER NOT NULL,
      FOREIGN KEY(app_id) REFERENCES apps(id),
    );
    ...
  SQL
  db.execute_batch(sql)
  </code></pre>
  
  <p>Unfortunately, I can happily insert rows into <code>requests</code> with unknown app-ids, it works, but of course it shouldn't.</p>
  
  <p>Interesting: using the sqlite3 shell directly, I can observe the following behaviour:</p>
  
  <pre><code>$ sqlite3 database.db
  sqlite&gt; PRAGMA foreign_keys = ON;
  sqlite&gt; PRAGMA foreign_keys;
  1 // as expected
  sqlite&gt; .quit
  $ sqlite3 database.db
  sqlite&gt; PRAGMA foreign_keys;
  0 // off ?!
  </code></pre>
  
  <p>Without quitting the sqlite3 shell, foreign keys <strong>are working</strong> after activating them (and not quitting the shell) and <strong>I'm not allowed</strong> to insert rows with unknown app_ids.</p>