On Saturday, May 9, 2015 at 2:54:15 AM UTC-7, fuuby wrote: > > Hello Everyone :) > > I just startet using Web2py and currently I am working on a little > project. Therefor I want to store data I selected with a > SQLTABLE(db().select(something)) from my database into a array (each result > into a seperate array "slot"). > Like I said, I am new to this and dont really know how to tackle this. > Thank you for your help, sorry for bad english >
Essentially, the results of a query is a ROWS object, which is something like an array (tuple) of ROW objects, which is more like a dict item, each key being a field name from the select. I'm not a heavy user of SQLTABLE; my oen example is doing my own query (db.executesql() is what I use, partly because that query compares some datatime entries, and then I dump the whole ROWS object into SQLTABLE to display. Elsewere, I do queries that don't end up in SQLTABLE, and I access fields by doing something like results = db.executesql(query-for-this-action) if results: lastrow = results[-1] value = lastrow['valfield'] # valfield is a field name, whichever one is of interest. This is showing you controller-side code, but the view-side version would be similar, with the '{{' and '}}' wrappers added. What sort of project are you working on at this point, so we can give more specific advice? Have you worked through the examples in the book (which is available online; see <URL:http://www.web2py.com/books/default/chapter/29/03/overview#Simple-examples> Good luck! /dps -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.