title: Pymysql insert foreign key error
body: <p>My table weather</p>
  
  <pre><code>create table weather (
              time timestamp default current_timestamp on update current_timestamp,
              id smallint,
              tpr float(3,1),
              wet float(3,1),
              uv tinyint(2),
              foreign key (id) references database.station(pk));
  </code></pre>
  
  <p>Table station</p>
  
  <pre><code>CREATE TABLE station(
  pk SMALLINT(5) NOT NULL AUTO_INCREMENT,
  name VARCHAR(5),
  lng DOUBLE(10,6),
  lat DOUBLE(10,6),
  PRIMARY KEY(pk));
  </code></pre>
  
  <p>When I use the pymysql to insert the id to the weather.</p>
  
  <p>I made the two functions below:</p>
  
  <pre><code>conn = pymysql.connect()#ignore the details
  def get_id_from_station():
      sql = """SELECT pk FROM  station """
      conn.cursor().execute(sql)
      id = conn.cursor().fetchone()[0]
      weather_saved(id)
  
  def weather_saved(id):
      #get the time,tpr,wet,uv value
      sql = """INSERT INTO weather (time,id,tpr,wet,uv) VALUES (%s,%s,%s,%s,%s)"""
      db.execute(sql, (time, id,tpr, wet, uv))
  </code></pre>
  
  <p>But the weather table didn't update.</p>
  
  <p>What's the wrong? </p>