python - Getting the column name of a specific data with sqlalchemy -
i using sqlalchemy 0.8 , want column name of input only, not column in table.
here code:
rec = raw_input("enter keyword search: ") res = session.query(test.__table__).filter(test.fname == rec).first() data = ','.join(map(str, res)) +"," print data #saw here @ not 1 wanted. displays of columns columns = [m.key m in data.columns] print columns
you can query columns want. if had model mymodel
can do:
session.query(mymodel.wanted_column1, ...) ... # rest of query
this select columns mentioned there.
you can use select syntax.
or if still want model object returned , columns not loaded, can use deferred column loading.