2007/5/15, Oleg Broytmann <phd@phd.pp.ru>:

> 1) How do I select all photos that have keyword1 AND keyword2?

photos = []
for photo on Photo.select():
   found = 0
   for keyword in photo.keywords:
      if keyword.keyword in ("test1", "TeSt2"):
         found += 1
   if found == 2:
      photos.append(photo)

 
Cool, this works. The only thing is, now it makes a query for every photo in the DB. Right now that would only be a couple thousand (3 I think), but that could be more than 10 thousand in a couple of years. Would this slow things really down with a SQLite db? And if so, is there another way to do this?

Another question bubbles up. Is there a way to create a dict out of a SelectResult? Or a JSONifiable object?