mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-25 01:26:23 -07:00
Add #if flag markers in sql macro script
Made some changes
This commit is contained in:
parent
72eb7e5467
commit
3905ec1393
4 changed files with 67 additions and 35 deletions
|
@ -15,14 +15,30 @@ macros = [
|
|||
macro("drop fk", "DROP CONSTRAINT", "DROP FOREIGN KEY")
|
||||
]
|
||||
|
||||
def compileOutIfs(text, flag):
|
||||
lines = text.splitlines()
|
||||
newText = ""
|
||||
compile = True
|
||||
for i in lines:
|
||||
if "#IF" in i:
|
||||
if flag in i:
|
||||
compile = True
|
||||
else:
|
||||
compile = False
|
||||
elif "#ENDIF" in i:
|
||||
compile = True
|
||||
elif compile:
|
||||
newText += i + "\n"
|
||||
return newText
|
||||
|
||||
def dofile(filestart):
|
||||
print("building " + filestart + " sql file")
|
||||
masterfileIn = open(filestart + "master.sql", 'r')
|
||||
masterfile = masterfileIn.read()
|
||||
masterfileIn.close()
|
||||
|
||||
postgresProcessed = masterfile
|
||||
mysqlProcessed = masterfile
|
||||
postgresProcessed = compileOutIfs(masterfile, "POSTGRES")
|
||||
mysqlProcessed = compileOutIfs(masterfile, "MYSQL")
|
||||
|
||||
for item in macros:
|
||||
macroCode = "{" + item.macroname + "}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue