yes a Row (a record is a dictionary) but you can do:

def make_run():
    siteList = []
    rows = db(db.websites).select(db.websites.URL).as_list()
    for row in rows:
        siteList.append(row.URL)
    return locals()

or

def make_run():
    rows = db(db.websites).select(db.websites.URL).as_list()
    siteList = [row.URL for row in rows]
    return locals()

On Monday, 10 August 2015 10:39:51 UTC-5, Jose W wrote:
>
> Hello,
>
> I am new to Web2py and I am running into an issue with making a query to 
> the DB, and returning a list of the filed values.
>
> Relevant Info:
> DB "db(db.websites).select(db.websites.URL)":
>   websites.URL
>   http://www.example.com
>   http://www.example.com
>   http://www.example.com
>   http://www.example.com
>   http://www.example.com
>   http://www.example.com
>   http://www.example.com
>   http://www.example.com
>
> Controller
> def make_run():
>     siteList = []
>     rows = db(db.websites).select(db.websites.URL).as_list()
>     for url in rows:
>         siteList.append(url)
>     return locals()
>
>
> View:
>   {{extend 'layout.html'}}
>
>
>   {{=siteList}}
>   <p>----</p>
>   {{=rows}}
>
>
>
> The problem is that my query is returning a list of dictionaries.  What I 
> am looking to get is a list of the filed values.
>
> *What I am getting from both the *siteList *and* rows *in my view**:*
> [{'URL': 'http://www.example.com'}, {'URL': 'http://www.example.com'}, 
> {'URL': 'http://www.example.com'}, {'URL': 'http://www.example.com'}, 
> {'URL': 'http://www.example.com'}, {'URL': 'http://www.example.com'}, 
> {'URL': 'http://www.example.com'}, {'URL': 'http://www.example.com'}, 
> {'URL': 'http://www.example.com'}]
>
> *What I am looking for:*
> [http://www.example.com, http://www.example.com, http://www.example.com, 
> http://www.example.com, http://www.example.com, http://www.example.com, 
> http://www.example.com, http://www.example.com, http://www.example.com]
>
> I know the problem is in my query, I just have not been able to figure out 
> the correct one to return a clean list. I have tried a couple of other 
> things with no success, like not using the .as_list() and using the loop to 
> build the list, but I get the response below:
> [<Row {'URL': 'http://www.example.com'}>, <Row {'URL': '
> http://www.example.com'}>, <Row {'URL': 'http://www.example.com'}>]
>
>
> Thanks in advance!
>

-- 
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.

Reply via email to