Hi,
There are several existing libraries for comparing SQL dump files and generate new dump file only containing the differences.
If you want to use pure python, we can use sql-dump-schema-diff
But if it's no need in completely python, there is a more mature solution: diffkit, it's written in java, we can compile it on linux. And of course we can use python to call it if you like
Thanks,