不是直接对比数据库,而是把数据库创建的sql导出来,对比sql,其实就是对比两个文本文件。
import re
def getPowerFile():
f = open("C:\\Users\\Administrator\\Desktop\\sql对比\\Z_T.sql", "r")
return f
def get主干数据库File():
f = open("C:\\Users\\Administrator\\Desktop\\sql对比\\I_T.sql", "r")
return f
def getDict(file, pattern, offset):
match = pattern.findall(file.read().lower())
retDict = {}
if match:
for index in range(len(match)):
#print(match[index])
wordList = match[index].replace('\n', ' ').replace(';', ' ').split(' ')
retDict[wordList[offset]] = match[index]
return retDict
def dumpDict(tmpDict):
for key in tmpDict:
print("-------------------------------")
print("key:", key)
print("value:\n", tmpDict[key])
#print("dict num : ", len(tmpDict))
def dumpList(tmpList):
if not tmpList:
print("空")
tmpList.sort()
for index in range(len(tmpList)):
print(tmpList[index])
#print("list num : ", len(tmpList))
def getNew(powerDict, 主干数据库Dict):
newList = []
for key in powerDict:
if key not in 主干数据库Dict:
newList.append(key)