If you're using psycopg2, then you may want to use the Diagnostics extension - check the documentation of psycopg2.
Gabor > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Krishnakant > Sent: 03 January 2016 08:16 > To: [email protected] > Subject: Re: [sqlalchemy] how to pick up constraint violation errors in > Alchemy > > > > On Sunday 03 January 2016 04:20 AM, Mike Bayer wrote: > > > > On 01/02/2016 01:02 PM, Krishnakant wrote: > >> hello all, > >> I wish to know how I can pick up the constraint failure errors in my code? > >> I think I would probably have to pick up the errors in a try: except: > >> system? > > that is correct. > > > >> But What is the exact way of picking up the message? > > You'd need to catch the type of exception, such as IntegrityError > > which is usually what you will get for a constraint violation. Beyond > > that, if you need to programmatically have more information you'd need > > to parse the text of the exception with a regular expression. > > So If the unique constraint is violated, then will I still have to see them > using > integrity exception? > > As I said I am using psycopg2 for postgresql. > Thanks for the tips. > happy hacking. > Krishnakant. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -------------------------------------------------------------------------------- NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies; do not disclose, use or act upon the information; and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
