Hi
1. I note that the code:
match_row = db(db.keywords.x.contains('|%s|' % keyword)).select().first().
This picks the first item in he list. How about a random search through the
list without using select().first()?

2. In my code:
 def types:
    db = DAL('sqlite.storage.db')
    db.define_table('types'
                    Field('body'))
    rows = db(db.types.body.id>0)select()
    for item in row:
        item = item
        return item.
I GET AN ERROR: NoneType item not iterable. I want the user to put in any
data e.g. '123' and if boolean(True) it prints out the answer.I am using
this code on a ython module imported to web2py and not in the controller.
In my view: {{=item}}

On Tue, Sep 9, 2014 at 4:21 PM, Maurice Waka <mauricew...@gmail.com> wrote:

> Hey thanks alot! let me work on this then.
> Kind regards
>
> On Tue, Sep 9, 2014 at 3:55 PM, Anthony <abasta...@gmail.com> wrote:
>
>> On Tuesday, September 9, 2014 8:40:04 AM UTC-4, Maurice Waka wrote:
>>>
>>> Thanks for the input. Yes it is part of a web2py app game.
>>> I have about 1000 rows, but when a user types in the keyword(stored in
>>> any of the rows) i should get a boolean answer which for now displays the
>>> row(different code on this)
>>>
>>
>> OK, but how are the rows stored in SQLite? Are they just strings, like
>> "['123', '1234', '12345', ]"? If so, you can do a query searching for the
>> string "'[keyword]'," within each row to return rows with a matching
>> keyword. Again, I would recommend using the DAL with a list:string field:
>>
>> db.define_table('keywords',
>>     Field('x', 'list:string'))
>>
>> This allows you to insert and extract actual Python lists from the field,
>> though the lists will be stored in the database as a string in the form
>> "|item1|item2|item3|". So, to find rows that match a keyword, you would
>> just do:
>>
>> keyword = '123' # in reality, this is obtained via user input
>> match_row = db(db.keywords.x.contains('|%s|' % keyword)).select().first()
>>
>> Your boolean test would then simply be "if match_row:". The list of
>> keywords in the matching row would be in match_row.x, which would be an
>> actual Python list rather than a string representation of a list.
>>
>> Anthony
>>
>> --
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/dNtVIOucH9Q/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Dr Maurice Waka, MBCHB.
> Nairobi
>



-- 
Dr Maurice Waka, MBCHB.
Nairobi

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