Hi Nachiketa,
On Wed, Nov 10, 2010 at 2:57 PM, Nachiketa Mishra <[email protected]> wrote:
> I have a type table with name, category_name and description and some audit
> columns. With Storm I am trying to just get these three columns. I am new to
> Storm and I am not able to figure out from the get_select_expr api
> documentation, how to just fetch these three columns.
Unless you want to perform a subselect, you don't need to use
get_select_expr. Given a class:
class Thing(Storm):
__storm_table__ = "thing"
id = Int(primary=True)
name = Unicode()
category_name = Unicode()
description = Unicode()
audit_stuff = Unicode()
You can get just the columns you want with:
result = store.find(Thing)
result = result.values(Thing.name, Thing.category_name, Thing.description)
for name, category_name, description in result:
print name, category_name, description
The ResultSet.values method is handy when you have a result set that
would normally yield objects, but for which you only want columns. If
you know you'll only ever want columns from the result set you can
specify them in the call to find:
result = store.find((Thing.name, Thing.category_name, Thing.description))
for name, category_name, description in result:
print name, category_name, description
I hope this helps!
Thanks,
J.
--
storm mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/storm