boys..... a select returns a list of rows. check_count=db(db.phalanx_request.url==single_md5_url[1]).select(db. phalanx_request.urlcount) returns something like [ {'urlcount' : 2 } ]
assuming you url is unique (because of the logic expressed in your snippet), then you'd like to fetch just the first row, and then the urlcount column value within it check_count=db(db.phalanx_request.url==single_md5_url[1]).select(db. phalanx_request.urlcount).first() if check_count: check_count = check_count.urlcount PS: a lot better would be was_it_updated = db(db.phalanx_request.url == thevalue).update(urlcount=db. phalanx_request.urlcount+1) if not was_it_updated: db.phalanx_request.insert(......) On Thursday, May 16, 2013 12:35:43 AM UTC+2, Nam Soo In wrote: > > I am still getting same error > > > On Wednesday, May 15, 2013 3:21:50 PM UTC-7, Derek wrote: >> >> Simple enough, check_count is a rows object, not an int. >> >> >> check_count=db(db.phalanx_request.url==single_md5_url[1]).select(db.phalanx_request.urlcount) >> >> That's a rowset. You'd want to probably just get the 'count' >> >> >> check_count=db(db.phalanx_request.url==single_md5_url[1]).select(db.phalanx_request.urlcount).count >> >> On Wednesday, May 15, 2013 3:00:55 PM UTC-7, Nam Soo In wrote: >>> >>> I am getting this error >>> <type 'exceptions.TypeError'> unsupported operand type(s) for +: 'Rows' >>> and 'int' >>> On Wednesday, May 15, 2013 1:59:41 PM UTC-7, Nam Soo In wrote: >>>> >>>> I am trying to update count depend on url exists in the DB >>>> urlcount is integer type in database >>>> It keeps giving me an error. >>>> >>>> Here is my code >>>> def storeMd5InDb(md5_url_list): >>>> import datetime >>>> >>>> for single_md5_url in md5_url_list: >>>> check_count=0 >>>> >>>> >>>> check_count=db(db.phalanx_request.url==single_md5_url[1]).select(db.phalanx_request.urlcount) >>>> if (check_count> 1): >>>> check_count=check_count+1 >>>> >>>> db(db.phalanx_request.url==single_md5_url[1]).update(count=check_count) >>>> else: >>>> >>>> >>>> db.phalanx_request.insert(md5=single_md5_url[0],url=single_md5_url[1],request_date=datetime.datetime.now(),status=False,urlcount=1) >>>> db.commit() >>>> >>>> Any thought? >>>> >>> -- --- 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/groups/opt_out.