Hi Massimo

Just came across this post and got a bit alarmed, so when i check if a 
record exists i don't have to use the usual '==' but instead '=' ?

On Monday, October 10, 2011 at 3:55:27 PM UTC+2, Massimo Di Pierro wrote:
>
> row = db.postcode_cache(postcode=postcode) 
> if not row: 
> db.postcode_cache.insert(postcode=postcode,nearset=nearest) 
> elif not row.nearest: row.update_record(nearset=nearest) 
> else: pass # do nothing 
>
> On Oct 10, 8:22 am, Chris Rowson <[email protected]> wrote: 
> > Hi list, 
> > 
> > I have a database table which looks like this: 
> > 
> > postcode_cache 
> > ------------------------ 
> > postcode (UNIQUE) 
> > lat 
> > lon 
> > nearest 
> > 
> > I want to test first whether or not a record exists for 'postcode' and 
> > if a record does exist, I want to check whether the 'nearest' field 
> > contains any data. 
> > 
> > I've tried this: 
> > 
> > if db(db.postcode_cache.postcode==postcode).select().first()==None: 
> >     create_a_new_postcode_record() 
> > 
> > elif 
> db(db.postcode_cache.postcode==postcode).select(db.postcode_cache.nearest)= 
> =None: 
> >     populate_the_nearest_field() 
> > 
> > else: 
> >     nothing_to_do() 
> > 
> > And while the check to establish whether or not a record exists seems 
> > to work, the check to see whether or not the 'nearest' field within 
> > the record is populated doesn't seem to work. 
> > 
> > Can anyone tell me what I'm doing wrong please? 
> > 
> > Thank you, 
> > 
> > Chris

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

Reply via email to