According to this: http://code.google.com/p/pyodbc/wiki/Errors it should not do so.
Can you provide an example of an error that raises IntegrityError but should not? Massimo On Jan 29, 10:23 am, NetHead <tbnethe...@yahoo.com> wrote: > Greetings everyone! > > This is my first post on this forum. My appreciation (in advance) > for any help any of you can lend me. > > SYNOPSIS: My app uses Web2py along with MS Sql Server. I placed a > unique constraint on a column in my SQL table, and if a user attempts > to enter a duplicate value in this column (and thus firing the SQL > UNIQUE constraint error), I want Web2py to gracefully flash a custom > error to the user. > > If MS SQL throws any other kind of non integrity-related errors, then > I would still like the Web2py ticket system to kick in and provide the > more informative message to the user. > > Here's the code I tried: > > try: > if items_form.accepts(request.vars,session,keepvalues=True) : > response.flash='Record was saved' > elif items_form.errors: > response.flash='Form has errors' > except IntegrityError: > response.flash='Possible Duplicate Item ID - Please try > again!' > > Which then generated this error ticket info: > > Traceback (most recent call last): > File "E:\Python\web2py_src\web2py\gluon\restricted.py", line 62, in > restricted > exec ccode in environment > File "E:\Python\web2py_src\web2py\applications\BossWalk/controllers/ > items.py", line 282, in <module> > File "E:\Python\web2py_src\web2py\gluon\globals.py", line 55, in > <lambda> > self._caller=lambda f: f() > File "E:\Python\web2py_src\web2py\applications\BossWalk/controllers/ > items.py", line 269, in items_upsert > except IntegrityError: > NameError: global name 'IntegrityError' is not defined > > NOTE: If I take the 'IntegrityError' string out of the 'Except' line, > the process does use 'flash' to show the custom error message when the > MS SQL unique constraint is violated. > > But..... I'm surmising that it will also show that *same* message if > ANY type of MS SQL exception gets thrown... not just the unique > constraint / integrity error. > > To summarize: I would like to flash the custom error when an SQL > integrity error is thrown, and fall back on the ticketing system if MS > SQL throws any other kind of error. > > Is this possible? > > Thanks!!! > > Todd B. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---