The error you are getting is a database error, not a web2py error, it says you are trying to insert a record with a duplicate id. Perhaps the data is already corrupted in db.
On Friday, 7 December 2012 00:06:43 UTC-6, Kenneth wrote: > > Hi, > > this is a legacy table and asset_id is the id for the table. So it needs > to be unique. The migration is false, web2py is not able to change the > structure at all. > > I'm only trying to update the asset_name not create an new that looks the > same. > > > Kenneth > > > Den fredagen den 7:e december 2012 kl. 04:10:24 UTC+2 skrev Massimo Di > Pierro: >> >> I suspect your asset_id is declared as unique (or was declared as unique, >> then you made a migration but db still thinks it is unique). >> >> On Thursday, 6 December 2012 17:37:10 UTC-6, Kenneth wrote: >>> >>> Hello, >>> >>> I have a form created by CRUD with some extra fields. assets_label field >>> is a dropdown consisting of all old labels. Beside that I add an normal >>> text field where user can enter a new label. >>> I have then crud.settings.create_onaccept = insert_assets where I update >>> the label name if there is some text in the textfield. This works great. >>> >>> The problem comes with crud.settings.update_onaccept = update_assets >>> and >>> def update_assets(form): >>> if form.request_vars.asset_name_2 != '': >>> row = db(db.assets.asset_id == form.vars.id).update(asset_name >>> = form.request_vars.asset_name_2) >>> >>> I get an error ticket containg: >>> <class '_mysql_exceptions.IntegrityError'> (1062, "Duplicate entry >>> '275-2012-12-07 10:26:41' for key 'asset_id'") >>> >>> >>> File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in >>> execute >>> self.errorhandler(self, exc, value) >>> File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in >>> defaulterrorhandler >>> raise errorclass, errorvalue >>> IntegrityError: (1062, "Duplicate entry '275-2012-12-07 10:26:41' for key >>> 'asset_id'") >>> >>> >>> Any ideas what I'm doing wrong? >>> >>> >>> Kenneth >>> >>> >>> --