title: InternalError: current transaction is aborted, commands ignored until end of transaction block ,on UNIQUE constraint
body: <p>I tried to get executed with my <code>except:</code> statement... while attempt to oppose the functionality of UNIQUE constraint..But ended with exceptional error..
  The Postgresql database table already contains the row that I have used in </p>
  
  <blockquote>
    <p>db.insert("The News","AparnaKumar",1995,234569654)</p>
  </blockquote>
  
  <p>but it works well on inserting unrepeated rows..</p>
  
  <pre><code>import psycopg2
  class database:
  
      def __init__(self):
  
          self.con=psycopg2.connect("dbname='book_store' user='postgres' password='5283' host='localhost' port='5432' ")
          self.cur=self.con.cursor()
          self.cur.execute("CREATE TABLE if not exists books(id SERIAL PRIMARY KEY,title TEXT NOT NULL UNIQUE,author TEXT NOT NULL,year integer NOT NULL,isbn integer NOT NULL UNIQUE)")
          self.con.commit()
  
      def insert(self,title,author,year,isbn):
        try:
          self.cur.execute("INSERT INTO books(title,author,year,isbn) VALUES(%s,%s,%s,%s)",(title,author,year,isbn))
          self.con.commit()
        except:
            print("already exists..")
  
      def view(self):
          self.cur.execute("SELECT * FROM books")
          rows=self.cur.fetchall()
          print(rows)
  
      def search(self,title=None,author=None,year=None,isbn=None):
          self.cur.execute("SELECT * FROM books WHERE title=%s or author=%s or year=%s or isbn=%s",(title,author,year,isbn))
          row=self.cur.fetchall()
          print(row)
  
  db=database()
  db.insert("The News","AparnaKumar",1995,234569654)
  db.view()
  db.search(year=1995)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MvtRb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MvtRb.png" alt="InternalError: current transaction is aborted, commands ignored until end of transaction block "></a></p>