That is one the restrictions when working with keyed tables.

Here are the original notes (see #5):

1) primarykey is a list of the field names that make up the primary
key
2) all primarykey fields will have NOT NULL set even if not specified
3) references are to other keyed tables only
4) references must use tablename.fieldname format, as shown above
5) update_record function is not available
6) web2py rev.1354 (or higher) has appadmin support for keyed tables.

It should be in the book but I don't see it...


On Nov 21, 12:28 pm, Dmitry Vukolov <dmitry.vuko...@gmail.com> wrote:
> Greetings!
>
> I seem to be having a problem using DAL with legacy databases, namely those
> without an existing AUTO_INCREMENT field:
>
> db.define_table('manufactured_by',
>     Field('product', 'string'),
>     Field('brand', 'string'),
>     primarykey=['product', 'brand'])
>
> With a similar setup the update() function works well:
>
> db.manufactured_by.insert(product="Perfume", brand="Chanel")
> rset = db(db.manufactured_by.product=="Perfume")
> rset.update(brand="Dior")
>
> Whereas the update_record() function throws an error -- KeyError:
> 'update_record':
>
> row = rset.select().first()
> row.update_record(brand="Fendi")
>
> Same for update_or_insert() which relies on calling update_record(). Tried
> with SQLite and MySQL backends. Is there any way to make those work?
>
> Many thanks!
>
> Dmitry
>
>  update_record_case.py
> < 1KViewDownload

Reply via email to