Skip to content
Snippets Groups Projects
Commit 6c5f4f6e authored by Adriaan Renting's avatar Adriaan Renting
Browse files

Task #10876: Changes as the result of testing and integration.

parent 99783196
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
import os
# This script reads infile and creates sql files for each part in the infile in the
# outdir directory. It also replaces references to the indatabase with references
# to the outdatabase.
......@@ -26,7 +26,11 @@ outIDMdatabase = "lofar_mom_test_rt_trigger_idm"
inUserAdmindatabase = "useradministration"
outUserAdmindatabase = "lofar_mom_test_rt_trigger_useradmin"
outfile = open(outdir +"000000_CREATE_DATABASE.sql", 'w')
if os.listdir(outdir) != []:
print "Output directory not empty! Aborting"
exit()
outfile = open(outdir + "000000_CREATE_DATABASE.sql", 'w')
# Please note that "Comments" in the SQL that look like this
# /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
......@@ -82,6 +86,7 @@ outfile = open(outdir +"000000_CREATE_DATABASE.sql", 'w')
# - Generated views for the BiRT viewer (starting with /*!50001 VIEW )
# - Comments
# - USE statements
# - Foreign keys
# We only check for these and not all lines of the SQL, as this saves having to parse the
# WRITE statements that are 99% of the SQL and by far the longest lines.
......@@ -94,7 +99,8 @@ possible_trigger = False
trigger = False
with open(infile) as f:
for line in f:
if not use_found or trigger or (line[0:13] == "/*!50001 VIEW") or (line[0:2] == '--'):
if not use_found or trigger or (line[0:13] == "/*!50001 VIEW") or (line[0:2] == '--') or \
"CONSTRAINT" in line[0:len("CONSTRAINT") + 2]:
# "/*!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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment