Hi all, I have a project in which I am supposed to use mysql. The database already made up. I am facing an issue with the primary key check. Whensover i insert a duplicate value for the primary key i end up with a ticket rather than a graceful handling. Here's the db model:
db.define_table('document', Field('sno','integer',requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'document.sno')]), Field('doc_no','string',requires=[IS_NOT_EMPTY()]), Field('issue','date',requires=[IS_NOT_EMPTY()]), Field('expiry','date',requires=[IS_NOT_EMPTY()]), Field('summary','text'), primarykey=['sno'], migrate=False, ) and the error that i receive when duplicating is : Traceback (most recent call last): File "/home/paresh/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/paresh/web2py/applications/DB/controllers/appadmin.py", line 410, in <module> File "/home/paresh/web2py/gluon/globals.py", line 96, in <lambda> self._caller = lambda f: f() File "/home/paresh/web2py/applications/DB/controllers/appadmin.py", line 125, in insert if form.accepts(request.vars, session): File "/home/paresh/web2py/gluon/sqlhtml.py", line 1135, in accepts pk = self.table.insert(**fields) File "/home/paresh/web2py/gluon/sql.py", line 2566, in insert return Table.insert(self,**fields) File "/home/paresh/web2py/gluon/sql.py", line 2037, in insert self._db._execute(query) File "/home/paresh/web2py/gluon/sql.py", line 989, in <lambda> self._execute = lambda *a, **b: self._cursor.execute(*a, **b) 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 '1-1' for key 'PRIMARY'") I would like to know that do i need to handle the integrity constraint myself or am i missing on some point.... Thanks for the help