import cx_Oracle import os db = cx_Oracle.connect('**********') print "Show Oracle Version: " + db.version cursor = db.cursor() sql = "select d.deployment_id from dpl_deployment d join dpl_deployment_file f on d.deployment_id = f.deployment_id where d.org_scope like '*:*' and (relative_path like '%merch%' or relative_path like '%item%') order by deployment_id desc" cursor.execute(sql) data = cursor.fetchall() cursor.close() db.close() print "the current dir and file: " +os.getcwd() os.listdir('/root/code') hf = open("./sql.out", 'r') history_num = hf.read() hf.close() f = open("./sql.out", "w") for row in data: for num in row: f.write(str(num)) f.write("\n") print num f.close() cf = open("./sql.out", 'r') current_num = cf.read() cf.close() if history_num==current_num: print 'no bad file found' else: print 'bad file found'