title: Flask with SQLite Encoding Issue
body: <p>I have the following code that is inserting JSON data into an SQLite database:</p>
  
  <pre><code># POST request here
  if request.headers['Content-Type'] == 'application/json':
      db = get_db()
      db.execute('insert into places (lat, long, address, name) values (?, ?, ?, ?)', [request.data[0], request.data[1], request.data[2], request.data[3]])
      db.commit()
  </code></pre>
  
  <p>and to retrieve that data:</p>
  
  <pre><code># GET request here
  if request.method == 'GET':
      db = get_db()
      cur = db.execute('select * from places order by id')
      entries = [dict(id=row[0], lat=row[1], long=row[2], address=row[3], name=row[4]) for row in cur.fetchall()]
      return repr(entries)
  </code></pre>
  
  <p>and my <code>get_db()</code> method used above:</p>
  
  <pre><code>def get_db():
      op = _app_ctx_stack.top
      if not hasattr(top, 'sqlite_db'):
          top.sqlite_db = sqlite3.connect(app.config['DATABASE'])
      return top.sqlite_db
  </code></pre>
  
  <p>Here is a sample cURL request that I'm doing:</p>
  
  <pre><code>curl -H "Content-type: application/json" -X POST http://127.0.0.1:5000/location -d '{'lat':5, 'long':10, 'address':'street', 'name':'work'}'
  </code></pre>
  
  <p>When trying to do a <code>GET</code> as follows: <code>curl -X GET http://127.0.0.1:5000/location</code>, I get:</p>
  
  <pre><code>[{'lat': u'{', 'address': u'a', 'id': 1, 'long': u'l', 'name': u't'}]
  </code></pre>
  
  <p>I believe that that is an encoding issue. Any advice on how I'm supposed to store the data to avoid this? What exactly is the issue here? </p>
  
  <p>Thanks!</p>