利用正则表达式对比数据库

该博客介绍了一种不直接对比数据库,而是通过导出数据库创建的SQL语句来对比两个数据库状态的方法,本质上是对两个文本文件进行比较。
摘要由CSDN通过智能技术生成

不是直接对比数据库,而是把数据库创建的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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值