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