title: SQLite insert statement failing silently using Flask
body: <p>I'm following along with the Flask/SQLite tutorial on the Flask website:
  <a href="http://flask.pocoo.org/docs/patterns/sqlite3/" rel="nofollow">http://flask.pocoo.org/docs/patterns/sqlite3/</a></p>
  
  <p>All of my select queries are working fine, but when I try an insert statement nothing happens. I get no error, but I also don't get an inserted row in my database. I'm not sure how to debug this when no error is happening. Does anyone have thoughts?</p>
  
  <p>Here's my setup code:</p>
  
  <pre><code>def connect_db():
      return sqlite3.connect(DATABASE)
  
  @application.before_request
  def before_request():
      g.db = connect_db()
  
  @application.teardown_request
  def teardown_request(exception):
      if hasattr(g, 'db'):
          g.db.close()
  
  def query_db(query, args=(), one=False):
      cur = g.db.execute(query, args)
      rv = [dict((cur.description[idx][0], value)
                 for idx, value in enumerate(row)) for row in cur.fetchall()]
      return (rv[0] if rv else None) if one else rv
  </code></pre>
  
  <p>Here's an example of a query that works:</p>
  
  <pre><code>@application.route('/api/galleries')
  def get_galleries():
      query = query_db('select id, title, thumbnail from galleries')
      return json.dumps(query)
  </code></pre>
  
  <p>And here's my insert statement. This one does nothing, with no errors:</p>
  
  <pre><code>g.db.execute('insert into photos (is_favorite, galleries_id, filename) values (?, ?, ?)', [is_favorite, galleries_id, filename])
  </code></pre>