Second option is better for me
On 4 Jan 2018 8:24 PM, "Dave S" <[email protected]> wrote:
>
>
> On Wednesday, January 3, 2018 at 10:48:32 PM UTC-8, Maurice Waka wrote:
>>
>>
>>
>>
>>
>>
>>
>> I have the following code for my DB:
>> dbmyhealth.define_table("health",
>> Field('name', 'string'),
>> Field('definition', 'text', length= 1000000,),
>> Field('abnval', 'text', length= 1000000,),
>> Field('normval', 'text', length= 1000000,),
>> Field('administration', 'text', length=
>> 1000000,),
>> Field('screening', 'text', length= 1000000,),
>> Field('causes', 'text', length= 1000000,),
>> migrate = False)
>>
>> rows = dbmyhealth().select(dbmyhealth.health.ALL)
>> for row in rows:
>> location0 = row.name
>> location1 = row.definition
>> location2 = row.abnvalinterpret
>> location3 = row.normvalinterpret
>> location4 = row.administration
>> location5 = row.screening
>> location6 = row.causes
>> corpus = [location1 , location2, location3, location4, location5,
>> location6]
>>
>> I want to select an item, including all the fields from the abnval to the
>> causes,not randomly but based on the ID or the name. If I use the limitby
>> constraint,I can get either the first, second, or last item based on the
>> selection used. If I use the below code, I get only the first item, which
>> is everything based on obesity. I want to select any item with every query
>> using either an ID or the names below e.g.
>> A code like:
>> for row in rows:
>> if id == 2
>> code..
>> corpus = [location1 , location2, location3, location4,
>> location5, location6]....in this case my corpus will have everything on
>> cardiomyopathy using the table details below.
>>
>> id name
>> 0. diabetes
>> 1. hypertension
>> 2. cardiomyopathy
>> 3. copd
>> 4. obesity
>>
>> So how do I code it to obtain my answer
>> Kind regards
>>
>>
> Wouldn't that be either of
>
> rows = dbmyhealth(dbmyhealth.health.id == 2).select()
>
>
>
> or (if you were doing more with the query)
>
> query = dbmyhealth.health.id == 2
> rows = dbmyhealth(query).select()
>
>
> ?
> (I didn't put in a first() because there's only 1 row with id == 2.)
>
> <URL:http://web2py.com/books/default/chapter/29/06/the-
> database-abstraction-layer#Query--Set--Rows>
>
> /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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/5DWqynKI_-g/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.