0

I have to parse a very complex dump (whatever it is). I have done the parsing through Python. Since the parsed data is very huge in amount, I have to feed it in the database (SQL). I have also done this. Now the thing is I have to compare the data now present in the SQL.

Actually I have to compare the data of 1st dump with the data of the 2nd dump. Both dumps have the same fields (attributes) but the values of their fields may be different. So I have to detect this change. For this, I have to do the comparison. But I don't have the idea how to do this all using Python as my front end.

1
  • What code do you have so far? Please post the code you've started with for doing this "compare". Commented Jun 1, 2009 at 9:45

2 Answers 2

1

If you don't have MINUS or EXCEPT, there is also this, which will show all non-matching rows using a UNION/GROUP BY trick

SELECT MAX(table), data1, data2
FROM (
    SELECT 'foo1' AS table, foo1.data1, foo1.data2 FROM foo1
    UNION ALL
    SELECT 'foo2' AS table, foo2.data1, foo2.data2 FROM foo2
) AS X
GROUP BY data1, data2
HAVING COUNT(*) = 1
ORDER BY data1, data2

I have a general purpose table compare SP which also can do a more complex table compare with left and right and inner joins and monetary threshold (or threshold percentage) and subset criteria.

Sign up to request clarification or add additional context in comments.

Comments

0

Why not do the 'dectect change' in SQL? Something like:

select foo.data1, foo.data2 from foo where foo.id = 'dump1'
minus
select foo.data1, foo.data2 from foo where foo.id = 'dump2'

1 Comment

Some database engines implement this functionality with the keyword EXCEPT, rather than MINUS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.