checker.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pum 作者: opengisch 项目源码 文件源码
def __check_equals(self, query):
        """Check if the query results on the two databases are equals.

            Returns
            -------
            bool
                True if the results are the same
                False otherwise
            list
                A list with the differences
        """
        self.cur1.execute(query)
        records1 = self.cur1.fetchall()

        self.cur2.execute(query)
        records2 = self.cur2.fetchall()

        result = True
        differences = []

        d = difflib.Differ()
        records1 = [str(x) for x in records1]
        records2 = [str(x) for x in records2]

        for line in d.compare(records1, records2):
            if line[0] in ('-', '+'):
                result = False
                if self.verbose_level == 1:
                    differences.append(line[0:79])
                elif self.verbose_level == 2:
                    differences.append(line)

        return result, differences
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号