[storm] How to convert a resultset into a dictionary?

Oscar Campos oscar.campos at member.fsf.org
Sun Apr 13 16:12:45 UTC 2014


Hi.

Let’s say that you have an User model:

user = store.find(User, User.email == ‘rpishcr at gmail.com’).one()
user_array = dict([(p.name, getattr(user, (p.name))) for p in user._storm_columns.values()])

Take into consideration that the former will work for simple properties, meaning that no references will be convert and returned as dictionary.

Regards

-- 
Join the free software foundation and become free as in freedom

On 13 April 2014 at 07:37:08, R Pish (rpishcr at gmail.com) wrote:

Hi,

What is the recommended way to convert a resultset produced by a call like: store.find(User, User.id == myvarid).one() ?

Thanks in advance
--  
storm mailing list  
storm at lists.canonical.com  
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/storm/attachments/20140413/d8770022/attachment.html>


More information about the storm mailing list