def putExceptions ( self, ch, zidx, resolution, annid, excstr, update=False ):
    """Store a list of exceptions"""
    """This should be done in a transaction"""

    # if in a TxN us the transaction cursor.  Otherwise create one.
    if self.txncursor is None:
      cursor = self.conn.cursor()
    else:
      cursor = self.txncursor


    if not update:

      sql = "INSERT INTO {} (zindex, id, exlist) VALUES (%s, %s, %s)".format( ch.getExceptionsTable(resolution) )
      try:
        cursor.execute ( sql, (zidx, annid, excstr))
      except MySQLdb.Error, e:
        logger.error ( "Error inserting exceptions %d: %s. sql=%s" % (e.args[0], e.args[1], sql))
        if self.txncursor is None:
          cursor.close()
        raise

    # In this case we have an update query
    else:

      sql = "UPDATE {} SET exlist=(%s) WHERE zindex=%s AND id=%s".format( ch.getExceptionsTable(resolution) )
      try:
        cursor.execute ( sql, (zlib.compress(excstr),zidx,annid))
      except MySQLdb.Error, e:
        logger.error ( "Error updating exceptions %d: %s. sql=%s" % (e.args[0], e.args[1], sql))
        if self.txncursor is None:
          cursor.close()
        raise

    # commit if not in a txn
    if self.txncursor is None:
      self.conn.commit()
      cursor.close()
dataset/ETHPy150Open neurodata/ndstore/ocpca/mysqlkvio.py/MySQLKVIO.putExceptions/original