python 监控oracle 数据库

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'

 

转载于:https://www.cnblogs.com/peter1994/p/7451755.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值