so from this code:
from dosql import *
import cgi
import simplejson as json
def index(req, userID):
userID = cgi.escape(userID)
get = doSql()
rec =
SELECT get_progressrecord(ID)
will return a single column of type record
.
SELECT * FROM get_progressrecord(ID)
will return multiple columns (matching your out
params).
As an aside, the fact that your output fields have no names might make your function a little difficult to work with. There's also an alternative syntax for RETURNS SETOF RECORD
which I find easier:
CREATE OR REPLACE FUNCTION get_progressrecord(int)
RETURNS TABLE(
height decimal(5,2),
weight decimal(5,2),
bmi decimal(4,2),
healthStatus text,
age int,
changePercentage decimal(4,2)
) AS
...
You can use map function for this aim :
Demo :
>>> tuple_list=[(300.00,30.00,3.33,'underweight',21,0.00),(300.00,30.00,3.33,'underweight',21,0.00)]
>>> map(list,tuple_list)
[[300.0, 30.0, 3.33, 'underweight', 21, 0.0], [300.0, 30.0, 3.33, 'underweight', 21, 0.0]]