title: SQLite3 insertion into foreign key table doesn't work
body: <p>I have an SQLite3 database running on a Python Flask server. I am trying to insert values into foreign key database but the values for the foreign key are set at Null.</p>
  <p>In my Flask application.py file:</p>
  <pre><code>from flask import Flask
  from cs50 import SQL
  
  
  app = Flask(__name__)
  db = SQL(&quot;sqlite:///test.db&quot;)
  
  db.execute(&quot;CREATE TABLE 'people' ('id' integer, 'name' varchar(100), PRIMARY KEY(id))&quot;)
  db.execute(&quot;CREATE TABLE 'friendships' (person_id INTEGER,'id' smallint, 'friends' boolean, FOREIGN KEY(person_id) REFERENCES people(id))&quot;)
  </code></pre>
  <p>At some point in the code I want to insert a 'friendship' into the referenced database, assuming I have two people with ids 1 and 2 in the 'people' table. Therefore, I run the code:</p>
  <pre><code>db.execute(&quot;INSERT INTO friendships (person_id, id, friends) VALUES (1, 2, 1)&quot;)
  </code></pre>
  <p>This leaves me with a null value for this inserted row in the person_id field, and have no clue why it has happened. I'm also unable to find anything on similar problems online, so I would really appreciate any help.</p>
  <p>Edit:
  The code works on itself but I tried to insert an input from a non-existent form input value of person_id from the client-side to the server. This resulted in null values being submitted to the server, consequently ending up in the database.</p>