|Come for the quick hacks, stay for the epiphanies.|
Masking data in a MySQL dump file. Ideas?by dliakh (Acolyte)
|on Oct 13, 2016 at 08:53 UTC||Need Help??|
dliakh has asked for the wisdom of the Perl Monks concerning the following question:
I have large MySQL dump files formatted as a set of SQL statements. The statements are the ones to set up the database structures and then to insert data into tables.
I need to process data in the files, remove sensitive data from certain columns, replace it with something other which looks like a valid data for each corresponding column, but doesn't contain any sensitive details. The output is going to be in the same format -- SQL formatted MySQL dump file.
This needs to be done without loading the contents of dump file into any database.
Looks like feasible. We read the file, recognize where the data fields start and end in the stream and replace those pieces of data with another data -- the 'anonymized' one.
The difficulties start with the realization that all the data in the INSERT statement is one long line with no end-of-line characters. Not a row of data per line -- just one long line which represents all data as ('column1', 'column2'),('a','b'),('something','something other') ...
Another piece of complexity comes with the realization that the data can contain embedded quotes, commas and parentheses.
The size of data being processed is much greater than the amount of RAM available on the machine which is doing the processing.
Can you please suggest some ideas about the possible implementation?