Created
October 25, 2014 22:24
-
-
Save fr3aker/f57781e5251af0ccfa1b to your computer and use it in GitHub Desktop.
very quick and dirty script to fix the new.sql file for Life is Feudal: Your Own server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
f = open("new.sql", "r") | |
content = f.read() | |
lines = content.split("\n") | |
i = 0 | |
# find all BEGIN statements for a CREATE | |
beginsInLines = list() | |
while i+1 < len(lines): | |
if lines[i] == "BEGIN": | |
beginsInLines.append(i) | |
i += 1 | |
# find CREATE for BEGIN | |
for lineNum in beginsInLines: | |
start = lineNum | |
lineNum -= 1 | |
while not lines[lineNum].startswith("CREATE"): | |
lineNum -= 1 | |
lines[lineNum] = "DELIMITER ~~~~\n" + lines[lineNum] | |
lineNum = start+1 | |
while not lines[lineNum] == "END;": | |
lineNum += 1 | |
lines[lineNum] = lines[lineNum] + "\n~~~~\nDELIMITER ;" | |
f = open("fixed_new.sql", "x") | |
f.write("\n".join(lines)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment