参考资料:
此脚本用于两个数据库之间的表、列、栏位、索引的差异对比。
cat oracle_diff.py
#!/home/dba/.pyenv/versions/3.5.2/bin/python
#coding=utf-8
import cx_Oracle
import time
import difflib
import os
v_host=os.popen('echo $HOSTNAME')
class Oracle_Status_Output():
def __init__(self,username,password,tns):
try:
self.db = cx_Oracle.connect(username,password,tns)
self.cursor = self.db.cursor()
except Exception as e:
print('Wrong')
print(e)
def schemas_tables_count(self,sql,db):
try:
self.cursor.execute(sql)
v_result=self.cursor.fetchall()
#print(v_result)
count = 0
for i in range(len(v_result)):
#print(v_result[i][1],'--',v_result[i][0])
count = int(v_result[i][0]) + count
print(db,'