访问Postgresql结果

时间:2013-07-19 03:53:58

标签: postgresql postgresql-9.1

我写了一个查询,它返回一个结果集,如下所示,

result = [
{"total_requests" : "4", "requesttimestamp" : null}, 
{"total_requests" : "2", "requesttimestamp" : null}, 
{"total_requests" : "4", "requesttimestamp" : null}, 
{"total_requests" : "7", "requesttimestamp" : null}, 
{"total_requests" : "1", "requesttimestamp" : 1.37412742E9}, 
{"total_requests" : "1", "requesttimestamp" : 1.37412781E9}, 
{"total_requests" : "1", "requesttimestamp" : 1.374127424E9}
]

当尝试迭代这个

result[i]["total_requests"] ,result[i]["requesttimestamp"] 

获取未定义的结果对。

那么如何单独检索值对?

1 个答案:

答案 0 :(得分:1)

可以通过result [i] .total_requests,result [i] .requesttimestamp

访问