def pgexecute(dbconn, oper, args=None):
    """Execute an operation using a cursor"""
    curs = dbconn.cursor()
    try:
        curs.execute(oper, args)
    except:
        curs.close()
        dbconn.rollback()
        raise
    return curs
