首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在瓶中检索SQLite条目

在瓶中检索SQLite条目
EN

Stack Overflow用户
提问于 2012-11-09 04:19:04
回答 1查看 1.3K关注 0票数 1

我第一次在SQLite上使用了烧瓶,并试图检索我刚刚插入到数据库中的数据。我的POST请求可以将JSON数据插入数据库(或者至少不会返回错误)。

我试图显示我插入的任何内容来验证和执行以下操作:

代码语言:javascript
复制
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还给你。为什么会发生这种情况?我只找到了两个例子,他们都在做我上面的事情。

编辑:

下面是烧瓶的错误:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-09 04:49:14

请返回return repr(entries)。视图应该返回字符串,而不是列表对象。无论出于什么原因,如果您返回一个列表,烧瓶将尝试并调用它,您将得到一个TypeError: 'list' object is not callable错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13302053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档