我第一次将 SQLite 与 Flask 一起使用,并尝试检索我刚刚插入数据库的数据。我将 JSON 数据插入数据库的 POST 请求工作正常(或至少不返回错误)。
我正在尝试显示我插入的任何内容以进行验证并按如下方式进行操作:
cur = db.execute('select * from places order by id')
entries = [dict(lat=row[0], long=row[1], address=row[2], name=row[3]) for row in cur.fetchall()]
return entries
我收到错误 500。为什么会这样?我只能找到两个做的例子,他们都在做我上面所说的。
编辑:
这是烧瓶的错误:
Traceback (most recent call last):
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/flask/app.py", line 1361, in full_dispatch_request
response = self.make_response(rv)
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/flask/app.py", line 1450, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/werkzeug/wrappers.py", line 711, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/werkzeug/wrappers.py", line 55, in _run_wsgi_app
return _run_wsgi_app(*args)
File "/Users/nayef/.virtualenvs/uber-api/lib/python2.7/site-packages/werkzeug/test.py", line 818, in run_wsgi_app
app_iter = app(environ, start_response)
TypeError: 'list' object is not callable