From ac2bfed1b7d8d70426e8fac0903c6954b82641c6 Mon Sep 17 00:00:00 2001 From: Adriaan Renting <renting@astron.nl> Date: Mon, 26 Jun 2017 12:21:02 +0000 Subject: [PATCH] Task #10876: made some changes to the script for omissions found during integration. --- ...rt_split_and_rename_mom_database_sqldump.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/support/tools/MoM/convert_split_and_rename_mom_database_sqldump.py b/support/tools/MoM/convert_split_and_rename_mom_database_sqldump.py index 2f4fe4609bb..04cb1fd2a27 100755 --- a/support/tools/MoM/convert_split_and_rename_mom_database_sqldump.py +++ b/support/tools/MoM/convert_split_and_rename_mom_database_sqldump.py @@ -7,13 +7,25 @@ # It creates separate files for filling the tables. # The script assumes the infile is a dump of a MySQL MoM 3 database. -# To use this script, change the first 4 variables defined below. +# To use this script, change the variables defined below. infile = "backup_lofar_mom3.sql.1" indatabase = "lofar_mom3" outdatabase = "lofar_mom_test_rt_trigger" outdir = "test/" +# You probably want to run this script on copies of lofar_mom3, lofar_mom3privileges +# useradministration and lofar_idm. +# The results can be fed to mysql with a command like: +# > ls -1 *.sql | awk '{ print "source",$0 }' | mysql --batch -u <user> -h mysqltest1.control.lofar -p<password> + +# If you leave these blank or have them the same as indatabase, the script will skip them. +# The core MoM database references these. +inIDMdatabase = "lofar_idm" +outIDMdatabase = "lofar_mom_test_rt_trigger_idm" +inUserAdmindatabase = "useradministration" +outUserAdmindatabase = "lofar_mom_test_rt_trigger_useradmin" + outfile = open(outdir +"000000_CREATE_DATABASE.sql", 'w') # Please note that "Comments" in the SQL that look like this @@ -86,6 +98,10 @@ with open(infile) as f: # "/*!50001 VIEW" are special BiRT viewer generated views if indatabase in line: #doing this for each line would be expensive line = line.replace(indatabase, outdatabase) + if inIDMdatabase and (indatabase != inIDMdatabase) and inIDMdatabase in line: + line = line.replace(inIDMdatabase, outIDMdatabase) + if inUserAdmindatabase and (indatabase != inUserAdmindatabase) and inUserAdmindatabase in line: + line = line.replace(inUserAdmindatabase, outUserAdmindatabase) if line[0:3] == "USE": if use_found: outfile = open(outdir + "%06d_" % line_nr + "USE_%s.sql" % outdatabase, 'w') -- GitLab