如何在查询响应中使用jsonify?

时间:2016-01-28 12:45:51

标签: python json flask flask-restful

使用flask-restful,并拥有一个存储与地点相关的数据库,名称,访问时间,退出时间和访问日期,我有这样的疑问:

component
  restpath = "test"
  rest     = true
{
  remove void function upload(
    required numeric id       restargsource = "Path"
  )
    httpmethod = "POST"
    restpath   = "{id}/"
    produces   = "application/json"
  {
    param name="form.document" type="string";
    param name="form.title"    type="string";

    if ( FileExists( form.document ) )
      restSetResponse({
        "status"  = 201,
        "content" = {
          "id"    = id,
          "title" = form.title,
          "size"  = GetFileInfo( form.document ).size
        }
      });
    else
      restSetResponse({
        "status"  = 400,
        "content" = "Nothing uploaded"
      });
  }
}

如何使用jsonify函数而不是像这样手动执行:

query = conn.execute("select * from geo_example where     init_hour='%d'"%hour_of_visit)

0 个答案:

没有答案