문제

I want to select distinct not null values from the database. This works:

db((db.task.workspace==270) & (db.task.i0!=None)).select(db.task.i0, distinct=True)

But I need to specify the column as a string and I have it stored in the "col" variable. I tried this, but it shows a blank value:

db((db.task.workspace==270) & (col!=None)).select(col, distinct=True)

How can I fix this?

도움이 되었습니까?

해결책

You can use dictionary notation to reference table fields, using the field name as the key:

db((db.task.workspace==270) & (db.task[col]!=None)).select(db.task[col], distinct=True)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top