On Wednesday, December 17, 2014 12:17:53 PM UTC-8, Oliver wrote:
>
> I'm getting "None" printed in the webpage. I'm trying to print all 
> first_name in the users table database.  I'm trying to follow the select 
> section in 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Query--Set--Rows
>
> I'm using MySQL for database and have few test records inserted in the 
> users table.  Please let me know what am I missing in the controller.  I 
> appreciate your help.  Thanks
>
>
> *My Model: *
>
> db.define_table('users',
>                 Field('first_name', 'text'),
>                 Field('last_name', 'text'))
>
> *My Controller:*
>
> def printall():
>         for row in db(db.users.id > 0).select(db.users.ALL):
> print row.first_name
>
> or
>
> def printall():
>     for row in db().select(db.users.ALL):
> print row.first_name
>


You are trying to print to the console for development purposes?

If you are showing a "None" as your result, then it appears your query 
isn't selecting any rows.  If you use the command line interface to your DB 
(sqlite3?) can you form a SQL SELECT command that retrieves the records you 
want?  If so, can you paste that command here?

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

Reply via email to