In
db.dogs.update_or_insert(db.dogs.dog_name == row.dog_name,
dog_name = row.dog_name,
flea_count = row.flea_name.count())
I do not see row.flea_dog_name'
Are sure this is the code?
On Sunday, 24 February 2013 09:02:30 UTC-6, Simon Ashley wrote:
>
> Having problems updating from with a row with a db.table.field.count()
> field (similarly with sum(), min(), max() etc.)
>
> i.e.
> def update_flea_count():
> query = db(db.fleas.id>0).select(db.fleas.dog_name,
> db.fleas.flea_name.count(), orderby=db.fleas.dog_name,
> groupby=db.fleas.dog_name)
> for row in query:
> db.dogs.update_or_insert(db.dogs.dog_name == row.dog_name,
> dog_name = row.dog_name,
> flea_count = row.flea_name.count())
>
> fails with
>
> File "C:/web2py16/applications/lconfirm/controllers/dogs.py"
> <http://127.0.0.1:8000/admin/default/edit/lconfirm/controllers/dogs.py>, line
> 29, in update_flea_count
> db.dogs.update_or_insert(db.dogs.dog_name == row.flea_dog_name,
> AttributeError: 'Row' object has no attribute 'flea_dog_name'
>
>
> but
>
> def update_flea_count():
> query = db(db.fleas.id>0).select(db.fleas.dog_name,
> db.fleas.flea_name.count(), orderby=db.fleas.dog_name,
> groupby=db.fleas.dog_name)
> form = SQLTABLE(query)
> return dict(form=form)
>
> works, as does an update without any db.fleas.flea_name.count() field in
> the select.
>
> Is there a way around this?
> (need to build analysis/ accumulation tables for management reporting)
> TIA
>
>
>
>
--
---
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/groups/opt_out.