Thanks for the tip.

"db('NOT %s' % (db.Record.Group_id!=ID |
db.Record.Name.belongs(List_of_names))).delete() " works, but its
always nice to have alternatives (especially alternatives that don't
force you to find the boolean complement of the expression each time).

btw, its not biggy, but just to let you know,
"db().select(db.Record.Name)" doesn't quite act like a tuple of 'Name'
strings even if you fetch only 1 field (I would have found it odd if
it had as it would have been inconsistent with how it behaves
otherwise when you get more than 1 field).

On Apr 1, 2:32 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> This will embed a sub query and use belongs on it.
>
> db((db.Record.Group_id == ID) &
> (db.Record.Name.belongs(db(db.Record.BloodType ==
> 'O-')._select()))).count()
>
> Alternatively for NOT
>
> db((db.Record.Group_id == ID) &
> (~db.Record.Name.belongs(db(db.Record.BloodType ==
> 'O-')._select()))).count()
>
> -Thadeus
>
>
>
> On Thu, Apr 1, 2010 at 12:01 PM, Magnitus <eric_vallee2...@yahoo.ca> wrote:
> > Thanks for both replies :).
>
> > So, if ``db().select(db.Record.Name)``  acts like a tuple, then I can
> > do something like this:
>
> > Names_in_db = db().select(db.Record.Name)
> > for Name in List_of_names:
> >    if Name in Names_in_db:
> >        #Update logic goes here
> >    else:
> >        #Insert logic goes here
>
> > Also, I have another question:
>
> > The belongs member function for DAL.Table.Field allows you to isolate
> > rows for which a particular field is in a given set of values.
>
> > Is there a short direct way to specify that you actually want to
> > isolate the rows for which a particular field is in the complement of
> > the set?
>
> > Likes (for example... actually, its pretty much what I'm trying to do
> > in my code):
>
> > db(db.Record.Group_id==ID & (!
> > db.Record.Name.belongs(List_of_names))).delete()
>
> > Note: The above syntax is not correct and gives an error, but it
> > illustrates what I'm trying to achieve.
>
> > On Apr 1, 10:30 am, Thadeus Burgess <thade...@thadeusb.com> wrote:
> >> ``db().select(db.Record.Name)`` returns a rows object, which acts like a 
> >> tuple.
>
> >> -Thadeus
>
> >> On Thu, Apr 1, 2010 at 5:06 AM, DenesL <denes1...@yahoo.ca> wrote:
> >> > thelist=[row.Name for row in db().select(db.Record.Name)]
>
> >> > On Apr 1, 1:41 am, Magnitus <eric_vallee2...@yahoo.ca> wrote:
> >> >> Hi,
>
> >> >> assuming that I have a "Record" table with a field called "Name" in
> >> >> the database (all also that there are a bunch of other fields for that
> >> >> table).
>
> >> >> Assume that I make the following query:
>
> >> >> Rows = db().select(db.Record.ALL)
>
> >> >> Is there a way to directly (with one line without having to iterate
> >> >> through each row and create the tuple/list manually) fetch the "Name"
> >> >> field for all the rows in a tuple/List?
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "web2py-users" group.
> >> > To post to this group, send email to web...@googlegroups.com.
> >> > To unsubscribe from this group, send email to 
> >> > web2py+unsubscr...@googlegroups.com.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/web2py?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to