Select defined with variable

25 views
Skip to first unread message

Simona Chovancová

unread,
Sep 19, 2017, 5:39:14 AM9/19/17
to web2py-users
I need to make a select like this:

db(db.table.id == 1).select(db.table.name, db.table.date).first()

but what attributes need to be selected always change so I'd need something like this:

selects = (db.table.name, db.table.date, ..)
db(db.table.id == 1).select(selects).first()

But this does not work, how do I determine what to select with a variable, if possible? Thanks.

Mirek Zvolský

unread,
Sep 19, 2017, 5:56:09 AM9/19/17
to web2py-users
Probably:
db(db.table.id == 1).select(*selects).first()
which in Python will unpack the parameters from an iterable (tuple here).

Jinak ... zdravim, a tesi me, ze nekdo dela pokusy s web2py.
Budes-li potrebovat nejakou pomoc nebo o tom chtit nekdy dat rec, kontakt je: zvo...@seznam.cz, 732457966.



Dne úterý 19. září 2017 11:39:14 UTC+2 Simona Chovancová napsal(a):
Reply all
Reply to author
Forward
0 new messages