Search code examples
pythonweb2py

web2py: getting field from rows object


The 'row' variable returns a single row but it appears the select statement returns a 'rows' object. I want to extract field a and field d from the 'row' variable.

I tried just doing row.a or row.d but this returns an error.

def d_comp():    

    c_id = request.args(0)
    evo_id = request.args(1)

    row = db((db.tbl_stat.c_id == c_id) & (db.tbl_stat.evo_type == evo_id)).select()

    c = db(db.tbl_c.id == c_id).select(db.tbl_c.ALL)

    a = 1

    d = 1

    p = 1

    return dict(c=c,a=a,d=d,p=p)

Solution

  • I solved the question by doing the following inside the html file:

    {{for val in row:}}
        {{=val.a}}
        {{=val.d}]
    {{pass}}