I have been messing around with web.py lately and wanted to grab some stuff from a db and its returning me a “Storage” object. an the code i am using to call my info is:
db = web.database(dbn='sqlite', db='sqlfile.sqlite')
sely = db.select('carp', order="id ASC")
when sely runs it drops me out text like so:
<Storage {'lvl': 0, 'symbol': u'formb', 'logged': u'false', 'id': 1, 'display': u'Classic'}>
when you print out sely the storage line comes out. how can i get the dictionary out of this object?
A general Python trick for dealing with unknown APIs is to use the
dirbuiltin. Trydir(sely)in the interpreter to see what member variables and functions are defined for the object you get.__iter__, you can calllist(sely)to convert the results to a list, and generally iterate over the object in a loop.__getitem__, then you can index into the object and hope to get a value back.As a side note, I just tried out your code and I get
selyto be aweb.utils.IterBetterinstance (which returns 0 rows, instead of expected 3 in my case). So I cannot really reproduce your problem (but have problems of my own, so to speak).