Skip to content

Instantly share code, notes, and snippets.

@fr3aker fr3aker/
Created Oct 25, 2014

What would you like to do?
very quick and dirty script to fix the new.sql file for Life is Feudal: Your Own server
#!/usr/bin/env python3
f = open("new.sql", "r")
content =
lines = content.split("\n")
i = 0
# find all BEGIN statements for a CREATE
beginsInLines = list()
while i+1 < len(lines):
if lines[i] == "BEGIN":
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.