Assuming by db_name you really mean the table name, maybe you want
something like this:
def db_query(tablename, fieldname):
query = (db[tablename].Financial_Institution == auth.user.id) & (db[
tablename].Completed == 1)
return db(query).select(db[tablename][fieldname]).first()[fieldname]
Do you really have multiple tables with Finacial_Institution and Completed
fields, and do you really need to do the same query on these tables, except
for returning different field values? Otherwise, it's not clear how useful
this function is?
Note, if you have a DAL table or field name in a variable, you can use
db[tablename][fieldname] and row[fieldname] syntax rather than
db.tablename.fieldname and row.fieldname (the latter syntax using dot
separators represents attribute retrieval and requires the literal
attribute names, not variables holding the names).
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.