db(db.items.id==int(row)).select(db.items.imageName)
returns a Rows
object, and its __str__
method converts it to CSV output, which is what you are seeing.
A Rows
object contains Row
objects, and a Row
object contains field values. To access an individual field value, you must first index the Rows
object to extract the Row
, and then get the individual field value as an attribute of the Row
. So, in this case, it would be:
db(db.items.id==int(row)).select(db.items.imageName)[0].imageName
or:
db(db.items.id==int(row)).select(db.items.imageName).first().imageName
The advantage of rows.first()
over rows[0]
is that the former returns None
in case there are no rows, whereas the latter will generate an exception (this doesn't help in the above case, because the subsequent attempt to access the .imageName
attribute would raise an exception in either case if there were no rows).
Note, even when the select returns just a single row with a single field, you still have to explicitly extract the row and the field value as above.