adamziel / mysql_merge Goto Github PK
View Code? Open in Web Editor NEWMerge 2+ mysql databases with ease
License: Do What The F*ck You Want To Public License
Merge 2+ mysql databases with ease
License: Do What The F*ck You Want To Public License
Hello,
First. I do not usually code in Python, so I had problems running it in version 3 of Python.
Second, there is a bug causing PK out of bounds.
If you have two databases: first_database, second_database
By incrementing first_database, you get primary keys like 1000001 and second_database primary keys like 2000001.
Then there is a step : " 7/9 Mapping pk in case of uniques conflict", which finds conflicts. In case of conflict second_database primary key change to 1000001.
In step 9: Decrementing pks: it tries to decrement - 2000000 primary keys in second database. But in those, where was conflict it goes out of bounds because it has changed.
my solution was to change function rollback_pks
where = ""
if len(table_map['pk_changed_to_resolve_unique_conficts']):
where = "WHERE %(pk_col)s NOT IN (%(ids)s)" % {
'pk_col': list(table_map['primary'].keys())[0],
'ids': ",".join(table_map['pk_changed_to_resolve_unique_conficts'])
}
self._logger.qs = "UPDATE `%(table)s` SET `%(pk)s` = `%(pk)s` - %(step)d %(where)s" % {"table": table_name,
"pk": col_name,
'step': self._increment_value,
'where': where}
where = ""
if len(table_map['pk_changed_to_resolve_unique_conficts']):
where = "WHERE %(pk_col)s IN (%(ids)s)" % {
'pk_col': list(table_map['primary'].keys())[0],
'ids': ",".join(table_map['pk_changed_to_resolve_unique_conficts'])
}
self._logger.qs = "UPDATE `%(table)s` SET `%(pk)s` = `%(pk)s` - %(step)d %(where)s" % {"table": table_name,
"pk": col_name,
'step': self._increment_step,
'where': where}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.